在多个分区上查询bigquery

时间:2020-11-12 08:52:16

标签: google-bigquery

我的bigquery表由名为business_day的列进行分区

我正在尝试获取特定business_days内的所有行。 例如,

select *
from table
where
    business_day >= "2018-12-01" and business_day <= "2019-01-01"
    or business_day >= "2019-12-01" and business_day <= "2010-01-01"
    or business_day >= "2020-12-01" and business_day <= "2021-01-01"

我收到此错误:

如果不对可用于分区消除的列“ business_day”进行过滤,则无法查询表“ table”

有没有不用UNION ALL来做到这一点的方法?

这是表格信息:

Table expiry: Never
Data location: EU
Table type: Partitioned
Partitioned by: Day
Partitioned on column: business_day
Partition filter: Required

我想念什么?

1 个答案:

答案 0 :(得分:1)

也许添加其他伪过滤器?但是,与UNION ALL相比,这可能会更加昂贵,因为它仍然可以读取不必要的分区:

select *
from table
where 
business_day >= "2018-12-01"
AND (business_day >= "2018-12-01" AND business_day <= "2019-01-01"
     OR business_day >= "2019-12-01" AND business_day <= "2010-01-01"
     OR business_day >= "2020-12-01" AND business_day <= "2021-01-01"
    )