简体   繁体   中英

Not getting result from ksql queries

I have a kafka cluster running locally and a topic named "my-topic" in which im pushing data. I also have the ksql server running and the query: SELECT*FROM "my-topic" gives me "my-topic does not exist". I understand that this query is not right and i would like to know if there is another way to query a topic.

the query: SELECT*FROM "my-topic" gives me "my-topic does not exist"

You can't do a SELECT directly against a Kafka topic in KSQL -- the only two statements in KSQL that allow you to work directly against topics are (1) PRINT <topic_name> and (2) SHOW TOPICS .

Instead, you need to create streams ( CREATE STREAM ) and/or create tables ( CREATE TABLE ) in KSQL, whose input data will be read and parsed from the desired Kafka topic. Think of streams and tables in KSQL as "Kafka topics with a schema" (see my recent write-up Of Streams and Tables in Kafka and Stream Processing, Part 1 for more information).

Example:

CREATE STREAM pageviews (viewtime BIGINT, userid VARCHAR, ...)
WITH (KAFKA_TOPIC='pageviews-topic', \
      VALUE_FORMAT='DELIMITED');

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