Confluent Platform: 6.1.1
Issue: Unable to see the data on ksql table:-
1.) First created topic:-
./kafka-topics --zookeeper localhost:2181 --create --partitions 1 --replication-factor 1 --topic COUNTRY-CSV
Created topic COUNTRY-CSV.
2.) Sent some data to this topic:-
./kafka-console-producer --broker-list localhost:9092 --topic COUNTRY-CSV --property parse.key=true --property key.separator=:
>AU:AU,Australia
>IN:IN,India
3.) Created KSQL table:-
ksql> CREATE TABLE COUNTRY_TABLE (countrycode VARCHAR PRIMARY KEY, countryname VARCHAR) WITH (KAFKA_TOPIC = 'COUNTRY-CSV', VALUE_FORMAT='DELIMITED');
Message
---------------
Table created
---------------
ksql>
4.) Already set the below property:-
ksql> SET 'auto.offset.xreset' = 'earliest';
Successfully changed local property 'auto.offset.reset' from 'earliest' to 'earliest'.
ksql>
5.) Not able to see the data onto the kSQL table:-
ksql> select countrycode, countryname from COUNTRY_TABLE EMIT CHANGES;
+---------------------------------------------------------------------------+---------------------------------------------------------------------------+
|COUNTRYCODE |COUNTRYNAME |
+---------------------------------------------------------------------------+---------------------------------------------------------------------------+
^CQuery terminated
ksql>
6.) Verified that data is coming well into the kafka topic, along with the KEY:-
ksql> print 'COUNTRY-CSV';
Key format: KAFKA_STRING
Value format: KAFKA_STRING
rowtime: 2021/05/09 09:34:23.799 Z, key: AU, value: AU,Australia
rowtime: 2021/05/09 09:34:29.185 Z, key: IN, value: IN,India
rowtime: 2021/05/09 09:34:39.701 Z, key: US, value: US,Unites-States
Unable to see the data (posted manually by Kafka console producer) onto the ksql table? Any help/pointers shall be highly appreciated..
Figured out the answer by going to the logs using confluent local current
:-
I was producing 2 columns in value separated by the comma, whereas in ksql-table, it was expecting only one column.
Worked with this data:-
./kafka-console-producer --broker-list localhost:9092 --topic COUNTRY-CSV --property parse.key=true --property key.separator=:
>JP:JAPAN
>AU:AUSTRALIA
>IN:INDIA
>BEL:BELGIUM
>SA:SOUTH-AFRICA
>GB:GREAT-BRITAIN
Obtained following output:-
ksql> select * from COUNTRY_CSV EMIT CHANGES;
+---------------------------------------------------------------------------+---------------------------------------------------------------------------+
|COUNTRYCODE |COUNTRYNAME |
+---------------------------------------------------------------------------+---------------------------------------------------------------------------+
|JP |JAPAN |
|AU |AUSTRALIA |
|IN |INDIA |
|BEL |BELGIUM |
|SA |SOUTH-AFRICA |
^CQuery terminated
ksql>
Thanks to all.
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.