Google bigquery BigQuery不';无法识别分区表谓词

Google bigquery BigQuery不';无法识别分区表谓词,google-bigquery,Google Bigquery,我在BigQuery中的timestamp列上有一个分区表,我希望提取过去96小时内发生的所有事件 WITH events AS ( SELECT concat(module, '_', replace(lower(action), ' ', '_')) type, detail, cast(IF(id=0, null, id) as string) id, timestamp, userId, pageName, FROM fe.logs l W

我在BigQuery中的
timestamp
列上有一个分区表,我希望提取过去96小时内发生的所有事件

WITH events AS (
SELECT
    concat(module, '_', replace(lower(action), ' ', '_')) type,
    detail,
    cast(IF(id=0, null, id) as string) id,
    timestamp,
    userId,
    pageName,
FROM fe.logs l
WHERE l.timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 96 HOUR)
   AND devicetype in ('desktop', 'mobile', 'tablet')
   AND osname in ('Windows', 'Android', 'Mac OS', 'iOS'))
SELECT TO_JSON_STRING(e) payload
from events e
但我一直在

Cannot query over table 'fe.logs' without a filter over column(s) 'timestamp' that can be used for partition elimination
我以为
其中l.timestamp>=timestamp\u SUB(CURRENT\u timestamp(),INTERVAL 96 HOUR)
可以作为分区列上的有效筛选器

为了完整起见,我已经从查询中删除了一些列名和WHERE条件,但都没有触及
timestamp
列,因此我认为它们在这里并不重要

E:实际上,我省略了(现在添加了)原始查询中的另一部分,该部分将所有行转换为JSON以使其尽可能完整


是否有一些特定的运算符或语法?

结果表明,在缩短此问题的代码时,我省略了包含错误的部分。做

WHERE l.timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 96 HOUR)
      AND predicate2
      OR predicate3
无效

完整的代码是

WITH events AS (
  SELECT
        concat(module, '_', replace(lower(action), ' ', '_')) type,
        detail,
        cast(IF(id=0, null, id) as string) id,
        timestamp,
        userId,
        pageName,
  FROM  fe.logs l
  WHERE l.timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 96 HOUR)
        AND devicetype in ('desktop', 'mobile', 'tablet')
        AND osname in ('Windows', 'Android', 'Mac OS', 'iOS')
        AND (module='bar' AND action='qux')
        OR (module='foo' AND action='baz') -- bug is here
)
SELECT TO_JSON_STRING(e) payload
from events e
在最初的代码中,我把括号弄乱了,应该是这样的

  WHERE l.timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 96 HOUR)
        AND devicetype in ('desktop', 'mobile', 'tablet')
        AND osname in ('Windows', 'Android', 'Mac OS', 'iOS')
        AND ((module='bar' AND action='qux')
          OR (module='foo' AND action='baz'))

您能否添加
和DATE(l.timestamp)>=DATE(timestamp\u SUB(CURRENT\u timestamp(),INTERVAL 96 HOUR))
的约束,并查看它是否有效?请参见此处的说明:。您需要将96小时逻辑添加到左侧,包括分区字段