我在数据集中有一系列表,需要在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)
但是,我在使用表格通配符时遇到麻烦。有人可以帮我解决语法问题吗?是否可以将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)
谢谢, 砂眼
答案 0 :(得分:17)
根据参考手册,FLATTEN语法为:
...(FLATTEN ([project_name:]datasetId.tableId, flattenField))..
...(FLATTEN (subselect_clause, flattenField))..
基于此,我会尝试在FLATTEN语句中添加一个subselect子句,如下所示:
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)
答案 1 :(得分:0)
试试这个,它对我有用..
SELECT
date,
customDimensions.value AS customDimension,
hits.page.pagePath AS pagePath
FROM
(FLATTEN (SELECT * 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)