我正在尝试从kafka中的现有主题创建ksql表。 当我查询表时,没有数据显示。
我尝试使用密钥将消息发送给kafka主题。这些在我创建的ksql流中可见,但是当我创建类似的表时,表中没有数据。
产生数据:
sh kafka-console-producer \
--broker-list kf-pranay-kafka-0.kf-pranay-kafka-headless.default.svc.cluster.local:9092 \
--topic ppp \
--property "parse.key=true" \
--property "key.separator=:"
1:{"sr":"1","title":"The Matrix","year":1999,"genres":"Science Fiction"}
2:{"sr":"2","title":"Die Hard","year":1988,"genres":"Action"}
3:{"sr":"3","title":"Toy Story","year":1995,"genres":"Animated"}
创建和查询流:
ksql> SET 'auto.offset.reset'='earliest';
Successfully changed local property 'auto.offset.reset' from 'earliest' to 'earliest'.
ksql>
ksql> CREATE STREAM ppp (sr varchar, title varchar, year bigint, genres varchar) WITH
>(kafka_topic='ppp', value_format='JSON');
Message
----------------
Stream created
----------------
ksql>
ksql> SELECT * FROM ppp;
1560340201759 | 1 | 1 | The Matrix | 1999 | Science Fiction
1560340201767 | 2 | 2 | Die Hard | 1988 | Action
1560340201767 | 3 | 3 | Toy Story | 1995 | Animated
^CQuery terminated
ksql>
ksql> CREATE TABLE movie_table (sr varchar, title varchar, year bigint, genres varchar) WITH
>(kafka_topic='ppp', value_format='JSON', key = 'sr');
Message
---------------
Table created
---------------
ksql>
ksql> SELECT * FROM MOVIE_TABLE;
^CQuery terminated
我期望表中的输出与来自STREAM的SELECT查询类似。但看来我表中没有任何数据。