Google Big Query Flatten表并使用table_range函数

Rac*_*hel 1 flatten google-bigquery

有谁知道如何同时使用多个FLATTEN函数和Table_date_range?现在我只能获得一天的数据,但我希望获得所有可用的数据.有办法吗?

select 
Date,COUNT(DISTINCT FULLVISITORID),hits.product.v2ProductCategory
FROM FLATTEN((FLATTEN (table, hits.product.v2ProductCategory)) ,customDimensions.value)
group by Date
,hits.product.v2ProductCategory
Run Code Online (Sandbox Code Playgroud)

谢谢

Ell*_*ard 5

您应该使用标准SQL.例如,

#standardSQL
SELECT
  Date,
  COUNT(DISTINCT FULLVISITORID),
  product.v2ProductCategory,
  customDimension.value
FROM `aaprod-20160309.112099209.ga_sessions_*` AS t
  CROSS JOIN UNNEST(hits) AS hit
  CROSS JOIN UNNEST(t.customDimensions) AS customDimension
  CROSS JOIN UNNEST(hit.product) AS product
GROUP BY 1, 3, 4;
Run Code Online (Sandbox Code Playgroud)

迁移指南中介绍了旧版和标准SQL之间的差异.