无法访问[1:104]上类型为ARRAY <struct <hitnumber int64,=“” time =“” int64,=“” hour =“” int64,=“” ... =“” >>的值的字段customDimensions ]

时间:2019-03-05 15:03:29

标签: google-bigquery gcloud

我是google bigquery的新手。我正在尝试从其中一个google bigquery数据集中获取数据,但低于错误screenshot attached

SQL查询:

SELECT  h.value
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_20170801`,
UNNEST(hits.customDimensions) AS h
LIMIT 10;

请让我知道我在做什么错。

1 个答案:

答案 0 :(得分:2)

hits是一个数组。您不能直接访问数组的元素。您需要取消嵌套数组的顺序才能生成可以引用的元素序列。您可能想取消hitscustomDimensions的嵌套:

SELECT cd.value
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_20170801`,
UNNEST(hits) AS h,
UNNEST(h.customDimensions) AS cd
LIMIT 10;

尽管customDimensions表中的每一行的bigquery-public-data.google_analytics_sample.ga_sessions_20170801数组都是空的,所以您将收到此查询的空结果集。实际上,如果您自己的表中有非空的customDimensions,则对其执行类似的查询将产生结果。