gpt4 book ai didi

google-bigquery - 使用 TABLE_DATE_RANGE 展平

转载 作者:行者123 更新时间:2023-12-03 13:33:02 25 4
gpt4 key购买 nike

我在数据集中有一系列表,需要在 FLATTENing 重复记录之一时查询所有表。例如,如下查询可以正常工作:

 SELECT
date,
customDimensions.value AS customDimension,
hits.page.pagePath AS pagePath
FROM
(FLATTEN( [<projectId>:<datasetId>.ga_sessions_20130910] ,
customDimensions))
WHERE
hits.page.pagePath CONTAINS '/helmets'
AND customDimensions.index IN (1,2,3)

但是,我在使用表通配符时遇到了 FLATTENing 问题。有人可以帮我解决语法吗?是否可以将 FLATTEN 与 TABLE_DATE_RANGE 一起使用?
SELECT
date,
customDimensions.value AS customDimension,
hits.page.pagePath AS pagePath
FROM
(FLATTEN (TABLE_DATE_RANGE ([<project>:<dataset>.ga_sessions_],
TIMESTAMP('2013-09-10'),
TIMESTAMP ('2014-06-10'))),
customDimensions)
WHERE
hits.page.pagePath CONTAINS '/helmets'
AND customDimensions.index IN (1,2,3)

谢谢,
沙岩

最佳答案

根据引用手册,FLATTEN 语法是:

...(FLATTEN ([project_name:]datasetId.tableId, flattenField))..
...(FLATTEN (subselect_clause, flattenField))..

基于此,我会尝试在 FLATTEN 语句中放置一个子选择子句,如下所示:
SELECT
date,
customDimensions.value AS customDimension,
hits.page.pagePath AS pagePath
FROM
FLATTEN(
(SELECT date, customDimensions, hits FROM TABLE_DATE_RANGE ([<project>:<dataset>.ga_sessions_],
TIMESTAMP('2013-09-10'),TIMESTAMP ('2014-06-10')))
, customDimensions)
WHERE
hits.page.pagePath CONTAINS '/helmets'
AND customDimensions.index IN (1,2,3)

关于google-bigquery - 使用 TABLE_DATE_RANGE 展平,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24189289/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com