BiqQuery Error: Cannot join on repeated field 'customDimensions.value'

BiqQuery Error: Cannot join on repeated field 'customDimensions.value'

我有以下 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

我收到错误:

Error: Cannot join on repeated field customDimensions.value

我看到您仍在使用 BigQuery Legacy SQL 所以下面是旧版 sql

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

Error: Cannot join on repeated field 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