clickhouse双分布式子查询被拒绝: select * from chuz_ods.ods_mes_sfc_all where toDate(partition_date) = yesterda

文章讨论了在ClickHouse中遇到的关于双分布子查询的限制,指出不支持直接使用IN/JOIN子查询。作者提供了使用GLOBAL关键字的解决方案,允许在子查询中执行全局查询以避免错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

select * from chuz_ods.ods_mes_sfc_all 
where toDate(partition_date) = yesterday() 
or partition_date in 
(select partition_date from chuz_ods.ods_mes_sfc_all 
where toDate(modified_date_time) = yesterday());

但是clickhouse是不是不支持这样的子查询呀? 会报以下错误:
SQL 错误 [288] [07000]: Code: 288. DB::Exception: Double-distributed IN/JOIN subqueries is denied (distributed_product_mode = ‘deny’). You may rewrite query to use local tables in subqueries, or use GLOBAL keyword, or set distributed_product_mode to suitable value.: While processing chuz_ods.ods_mes_sfc_all: While processing partition_date IN (SELECT partition_date FROM chuz_ods.ods_mes_sfc_all WHERE toDate(modified_date_time) = yesterday()).

select * from chuz_ods.ods_mes_sfc_all 
where toDate(partition_date) = yesterday() 
or toDate(partition_date) GLOBAL in 
(select toDate(partition_date) 
from chuz_ods.ods_mes_sfc_all 
where toDate(modified_date_time) = yesterday());

这个解决方案使用GLOBAL关键字告诉ClickHouse在子查询中执行全局查询,从而绕过了双分布式子查询的限制。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值