-
Notifications
You must be signed in to change notification settings - Fork 0
/
select-topic-with-dots-different-projection.sql
59 lines (51 loc) · 1.34 KB
/
select-topic-with-dots-different-projection.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
-- create using Control center (http://localhost:9021) the topic "topic_underscore.dots"
-- set an schema for the topic
{
"type": "record",
"namespace": "com.mycorp.mynamespace",
"name": "sampleRecord",
"doc": "Sample schema to help you get started.",
"fields": [
{
"name": "f1",
"type": "int"
},
{
"name": "f2",
"type": "string"
},
{
"name": "f3",
"type": "string"
}
]
}
-- produce some data
kafka-avro-console-producer --bootstrap-server localhost:9092 --topic topic_underscore.dots --property schema.registry.url=http://localhost:8081 --property value.schema.id=1
{ "f1": 1, "f2" : "one", "f3" : "one" }
{ "f1": 2, "f2" : "two", "f3" : "two" }
-- consume the data
kafka-avro-console-consumer --topic topic_underscore.dots --from-beginning --bootstrap-server localhost:9092 --property schema.registry.url=http://localhost:8081 --property print.schema.ids=true
-- create the stream
CREATE STREAM NEW_NAME (
f1 INT,
f2 STRING
)
WITH (
KAFKA_TOPIC='topic_underscore.dots',
VALUE_FORMAT='AVRO'
);
CREATE STREAM NEW_NAME2 (
f1 INT,
f2 STRING,
f3 STRING
)
WITH (
KAFKA_TOPIC='topic_underscore.dots',
VALUE_FORMAT='AVRO'
);
-- check results
select * FROM NEW_NAME;
select * from NEW_NAME where f1 = 1;
select * FROM NEW_NAME2;
select * from NEW_NAME2 where f1 = 1;