BiqQuery错误:无法加入重复字段'customDimensions.value'

时间:2018-04-17 15:43:23

标签: sql google-bigquery legacy-sql

我有以下SQL语句,简而言之,table包含我需要获取过去一年网站行为的id列表。这些id应与customDimensions.value

匹配
SELECT fullVisitorId, visitNumber, totals.pageviews, customDimensions.value as client_id
FROM (
SELECT * FROM
  TABLE_DATE_RANGE([xxxxxxx.ga_sessions_],
                    TIMESTAMP('2017-01-01'),
                    TIMESTAMP('2018-01-01'))
                    )
WHERE customDimensions.index = 2 AND customDimensions.value IN (SELECT STRING(id) FROM [table])
GROUP BY 1,2,3,4

我收到错误:

  

错误:无法加入重复字段customDimensions.value

1 个答案:

答案 0 :(得分:1)

我发现你仍然使用BigQuery Legacy SQL,所以下面是遗留sql

假设原始查询的其余部分符合您的要求 - 它会解决以下错误

  

错误:无法加入重复字段customDimensions.value

   
#legacySQL
SELECT fullVisitorId, visitNumber, totals.pageviews, customDimensions.value AS client_id
FROM FLATTEN((
SELECT * FROM
  TABLE_DATE_RANGE([xxxxxxx.ga_sessions_],
                    TIMESTAMP('2017-01-01'),
                    TIMESTAMP('2018-01-01'))
                    ), customDimensions)
WHERE customDimensions.index = 2 AND customDimensions.value IN (SELECT STRING(id) FROM [table])
GROUP BY 1,2,3,4