简体   繁体   English

Kafka select 对表的 KSQL 查询不返回任何内容

[英]Kafka select KSQL query on table return nothing

i try repeat create Ktable and select by manual https://docs.ksqldb.io/en/latest/developer-guide/create-a-table/我尝试通过手动https://docs.ksqldb.io/en/latest/developer-guide/create-a-table/ 重复创建 Ktable 和 select

Select from topic kafkacat -b broker:9092 -t videos : Select 来自主题kafkacat -b broker:9092 -t videos

{"VideoId":"304b3306-c3d6-47c8-a936-c0e2d4d375ee","UserId":"7c8266d7-fea7-49c1-8fc2-aff47a9c19e5"}

Create Ktable from topic从主题创建 Ktable

create table videos_table (VideoId varchar, UserId varchar) WITH (KAFKA_TOPIC = 'videos', KEY = 'VideoId', VALUE_FORMAT='json');

Info: show tables ;信息: show tables

 Table Name  | Kafka Topic | Format | Windowed 
-----------------------------------------------
 VIDEOS_TABLE | videos       | JSON   | false    
-----------------------------------------------

Select from table: SELECT * FROM videos_table EMIT CHANGES ; Select 来自表: SELECT * FROM videos_table EMIT CHANGES

I have nothing on screen.我在屏幕上什么都没有。 Then i insert new msg to topic, i see it in kafkacat, but this select no print nothing.然后我将新的味精插入主题,我在 kafkacat 中看到它,但是这个 select 没有打印任何内容。 On manual they have result:在手册上,他们有结果:

screen from manual, they have result手册中的屏幕,他们有结果

what am I doing wrong?我究竟做错了什么?

By default, ksqlDB reads from the end of a topic.默认情况下,ksqlDB 从主题的末尾读取。 A query does not return results if no new messages are being written to the topic.如果没有新消息写入主题,则查询不会返回结果。

Make sure that auto.offset.reset is set to earliest so that ksqldb reads from the beginning of a topic.确保auto.offset.reset设置为earliest ,以便ksqldb从主题的开头读取。 Finally re-run your queries and all the data should now be visible.最后重新运行您的查询,所有数据现在应该是可见的。


SET 'auto.offset.reset'='earliest';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM