是否可以在KSQL中连接两个以上的流/表?
示例:
我有三个流:
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');
我尝试通过加入这三个流来创建另一个流:
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;
我收到以下异常:
mismatched input 'JOIN' expecting ';'
Caused by: org.antlr.v4.runtime.InputMismatchException
答案 0 :(得分:2)
否,您最多只能在V5.0以下的KSQL中将每个查询连接两个。您需要使用菊花链式查询,如下所示:
中间流:
CREATE STREAM ABStream AS \
SELECT * \
FROM StreamA a \
JOIN StreamB b \
ON b.aid = a.id;
多联接流
CREATE STREAM ABCStream AS \
SELECT * \
FROM ABStream AB \
JOIN StreamC c \
WITHIN 1 HOURS \
ON c.bid = AB.b_id;