KSQL:无效的连接条件:当连接超过 2 个表时,不支持将外键表-表连接作为 n 路的一部分

发布于 2025-01-10 04:48:21 字数 643 浏览 0 评论 0原文

我有 3 个主题,其中包含 KAFKA_INT 关键

客户、订单、订单详细信息

当我仅连接 2 个表时


select * from orders o join customer c on o.custid = c.custid emit changes; -- OK 

select od.id, od.orderid from orderdetails od join orders o on od.orderid = o.orderid emit changes; -- OK


-- NOT OK
 
select * from orderdetails od
join order o on od.orderid = o.orderid
join customer c on o.custid = c.custid
emit changes limit 5; 

-- Error
Invalid join condition: foreign-key table-table joins are not supported as part of n-way joins. Got o.custid = c.custid.

但是,我找不到任何文档如何连接多个表以及它的限制是什么。

我正在使用 Confluence KAFKA HELM 版本 7.0

I have 3 topics with KAFKA_INT key

customer,orders,orderdetails

When i do joining 2 tables only


select * from orders o join customer c on o.custid = c.custid emit changes; -- OK 

select od.id, od.orderid from orderdetails od join orders o on od.orderid = o.orderid emit changes; -- OK


-- NOT OK
 
select * from orderdetails od
join order o on od.orderid = o.orderid
join customer c on o.custid = c.custid
emit changes limit 5; 

-- Error
Invalid join condition: foreign-key table-table joins are not supported as part of n-way joins. Got o.custid = c.custid.

However, I couldn't find any documentation how can multiple tables join work and what is the limitation of it.

I am using Confluent KAFKA HELM version 7.0

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那伤。 2025-01-17 04:48:21

正如错误消息所述,ksqldb 不支持表到表多重联接(n 路联接)。为了进行该连接,您可能需要创建一个中间支持表。像这样:

CREATE TABLE orderdetails_join_order AS 
SELECT *
FROM orderdetails od
JOIN order o ON od.orderid = o.orderId;

现在您可以使用此表来执行查询:

SELECT * FROM orderdetails_join_order odjo
JOIN customer c ON odjo.custid = c.custid

Table to table multi joins (n-way joins) are not supported in ksqldb as the error message says. In order to make that joins probably you will need to make an intermediate support table. Something like this:

CREATE TABLE orderdetails_join_order AS 
SELECT *
FROM orderdetails od
JOIN order o ON od.orderid = o.orderId;

Now you can use this table to perform your query:

SELECT * FROM orderdetails_join_order odjo
JOIN customer c ON odjo.custid = c.custid
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文