gpt4 book ai didi

join - KSQL 加入两个以上的流

转载 作者:行者123 更新时间:2023-12-01 12:09:32 25 4
gpt4 key购买 nike

在 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

最佳答案

不,您只能在 KSQL v5.0 之前的每个查询中连接两个。您需要菊花链式查询,如下所示:

中间流:

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;

关于join - KSQL 加入两个以上的流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53081076/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com