I'm a new bee to ksql. I'm just playing with read kafka topics to streams and it works great.
Also, trying to create a table from kafka topic and failed. Realized that I need to have a key set in kafka topic which is considered as primary key in ksql table. So I tried creating table from stream instead, but failed too. Query/Script:
CREATE TABLE DETAILS_TABLE AS SELECT SEQ, Server1, ServerId, NumberUri, SERVERID2, SERVER2 FROM details_stream WINDOW TUMBLING (SIZE 1 MINUTES);
Invalid result type. Your SELECT query produces a STREAM. Please use CREATE STREAM AS SELECT statement instead.
Can someone explain if its possible or not? If yes, wher am I going wrong? Thanks.
When navigating to a Kafka topic, you can query all existing data and the live stream. Lenses immediately presents a snapshot of the latest data in table browsing mode allowing: To Filter by timestamp, offset or partition. To Drill into the data and expand the key and value payloads and any nested fields.
KSQL is ready for production use, and integrated into CP.
For the purposes of this topic, "ksqlDB" refers to ksqlDB 0.6. 0 and beyond, and "KSQL" refers to all previous releases of KSQL (5.3 and lower). ksqlDB is not backward compatible with previous versions of KSQL. This means that, ksqlDB doesn't run over an existing KSQL deployment.
As Matthias says, you need to specify a (valid) aggregate query.
So this would work:
CREATE TABLE DETAILS_TABLE AS \
SELECT SEQ, Server1, ServerId, NumberUri, SERVERID2, SERVER2, COUNT(*) AS TOTAL \
FROM details_stream WINDOW TUMBLING (SIZE 1 MINUTES) \
GROUP BY SEQ, Server1, ServerId, NumberUri, SERVERID2, SERVER2;
Just as any SQL dialect, if you are doing an aggregation, you have to GROUP BY
all of the fields, otherwise it makes no syntactical sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With