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在子查询中执行全局查询,从而绕过了双分布式子查询的限制。