Is it possible to join more than two streams/tables in KSQL?
Example:
I have three streams:
CREATE STREAM StreamA (id BIGINT, message VARCHAR) WITH
(KAFKA_TOPIC='TopicA', VALUE_FORMAT='DELIMITED');
CREATE STREAM StreamB (id BIGINT, aid BIGINT, message VARCHAR) WITH .
(KAFKA_TOPIC='TopicB', VALUE_FORMAT='DELIMITED');
CREATE STREAM StreamC (id BIGINT, bid BIGINT, message VARCHAR) WITH
(KAFKA_TOPIC='TopicC', VALUE_FORMAT='DELIMITED');
I try to create another stream by joining those three streams:
CREATE STREAM ABCStream AS SELECT * FROM StreamA a JOIN
StreamB b ON b.aid = a.id JOIN StreamC c WITHIN 1 HOURS ON
c.bid = b.id;
I get the following exception:
mismatched input 'JOIN' expecting ';'
Caused by: org.antlr.v4.runtime.InputMismatchException
No, you can only join two per query in KSQL up to v5.0. You'd need to daisy-chain your queries, something like this:
Intermediate Stream:
CREATE STREAM ABStream AS \
SELECT * \
FROM StreamA a \
JOIN StreamB b \
ON b.aid = a.id;
Multi- join stream
CREATE STREAM ABCStream AS \
SELECT * \
FROM ABStream AB \
JOIN StreamC c \
WITHIN 1 HOURS \
ON c.bid = AB.b_id;
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.