简体   繁体   中英

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/

Select from topic kafkacat -b broker:9092 -t videos :

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

Create Ktable from topic

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

Info: show tables ;

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

Select from table: 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. 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. 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. Finally re-run your queries and all the data should now be visible.


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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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