Jagadeesh Musham
Jagadeesh Musham

Reputation: 89

not able to access kafka data by using KSQL tables

Kafka topica name: test

Following is the data in the test topic:

{"a":1,"b":"a"} {"a":2,"b":"b"}

Created the stream for this as:

CREATE STREAM test_stream123 (a INTEGER, b VARCHAR) WITH (kafka_topic='test', key='b', value_format='json');

This is working fine and even Select command also fetching data properly.

But the problem is with tables.

Following command is used to create the table for above topic:

CREATE TABLE test_table (a INTEGER, b VARCHAR) WITH (kafka_topic='test', value_format='json', key='b');

Create table also worked fine and the response clearly stated about "table created".

But,

When I tried to fetch the data from Kafka by using below command:

*select * from test_table EMIT CHANGES;*

it first showing following text: => Press CTRL-C to interrupt

And when I press the Ctrl-C, it giving following message:

+-----------+-----------+-----------+-----------+ |ROWTIME |ROWKEY |A |B | +-----------+-----------+-----------+-----------+ Query terminated

It is giving empty data even the data is available in Kafka topic. Streams are worked perfectly but Tables are not working.

View Jagadeesh’s profileJagadeesh Musham

Seems to be like I am doing some minor mistake while dealing with KSQL tables. Could you suggest me how to come out from this. or send me some links so that I will go through with all that material and try to solve the case.

Upvotes: 0

Views: 207

Answers (1)

Jagadeesh Musham
Jagadeesh Musham

Reputation: 89

KSQL tables display the Kafka entries only when Kafka entries have key. That means kafka producer has to produce the entries by using the key value.

Following is detailed explanation on this: https://github.com/confluentinc/ksql/issues/1405

--Jagadeesh

Upvotes: 1

Related Questions