简体   繁体   中英

KSQL: (pull)-query on a joined table

I have two topics that I'd like to join and then query the join for the latest results. I have followed the docs on Create a ksqlDB Table from a ksqlDB Stream from here .

This is what I do:

CREATE TABLE CATALOGUE_TABLE
  (title STRING)
  WITH (KAFKA_TOPIC='catalogue-topic-test',
        VALUE_FORMAT='AVRO');
CREATE TABLE SCHEDULE_TABLE
  (fromInstant STRING,
   toInstant STRING)
  WITH (KAFKA_TOPIC='schedule-topic-test',
        VALUE_FORMAT='AVRO');

rest assured that the two underlying topics both have keys for all their entries. I then join them like this:

CREATE TABLE MYTABLE AS
  SELECT c.title, s.fromInstant, s.toInstant
  FROM CATALOGUE_TABLE c
  INNER JOIN SCHEDULE_TABLE s
  ON s.ROWKEY = c.ROWKEY
  EMIT CHANGES;

I am not sure what I end up with it. whatever it is, I can run the following on:

select * from MYTABLE EMIT CHANGES;

and I can see all the updates on it, with all the duplicates. it's bascially a stream. Now if I run the following:

select * from MYTABLE WHERE ROWKEY='12';

to get the last update with id=12, I get:

Table 'MYTABLE' is not materialized. Refer to https://cnfl.io/queries for info on query types. If you...

and the rest of the output is truncated so I can't see what it's trying to say. My guess is that I am somehow doing something wrong in MYTABLE.

I think I am missing a groupBy which would should be the piece responsible for getting rid of all the entries with repeated ids, but I can't figure out what I need to put there and whether I should do so at the MYTABLE level only, or if it should be done on all three tables.

Currently, ie, ksqlDB 0.6.0, only stream aggregation queries that return a table allow to query the result table.

For a table-table join, the result is not materialized into a local store, but only a changelog stream is produced and written to the result topic that corresponds to the result table.

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