简体   繁体   中英

KSQL table not showing data but Stream with same structure returning data

I have created a table in KSQL, while querying it's not returning any data. Then I created a stream on the same topic with same structure and I am able to query the data.

What am I missing here. I need this as a table for joining with a stream.

CREATE TABLE users_table \
(registertime bigint, userid varchar, regionid varchar, gender varchar) \
WITH (value_format='json', kafka_topic='users_topic',key='userid');

and

CREATE STREAM users_stream \
(registertime bigint, userid varchar, regionid varchar, gender varchar) \
 WITH (value_format='json', kafka_topic='users_topic');

Thanks in advance.

If you read a topic as a TABLE the messages in the topic must have the key set. If the key is null , records will be dropped silently. A key in a KSQL TABLE is a primary key and null is no valid value for a primary key.

Furthermore, the value in the message of the key attribute, must be the same as the key (note, that the schema itself is define on the value of the message). For example, if you have a schema, <A,B,C> and you set A as the key, the messages in the topic must be <key,value> == <a,<a,b,c>> . Otherwise, you will get incorrect results.

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