【问题标题】:Cannot access field customDimensions on a value with type ARRAY<STRUCT<hitNumber INT64, time INT64, hour INT64, ...>> at [1:104]无法访问类型为 ARRAY<STRUCT<hitNumber INT64, time INT64, hour INT64, ...>> at [1:104] 的字段 customDimensions
【发布时间】:2019-07-27 02:17:25
【问题描述】:

我是 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;

请让我知道什么错误,我在这里做。

【问题讨论】:

    标签: google-bigquery gcloud


    【解决方案1】:

    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,则对其运行类似的查询会产生结果。

    【讨论】:

    • 如果对您有用,请将答案标记为已接受;见stackoverflow.com/help/someone-answers
    • ,我已将答案标记为已接受,但由于我的声誉低于 15,因此不会公开显示。 “感谢您的反馈!声望低于 15 人的投票将被记录,但不要更改公开显示的帖子得分”
    • @sam:接受答案(即绿色复选标记)与投票不同。无论如何,现在你也有足够的代表来投票了。 :)
    猜你喜欢
    • 2016-12-30
    • 2021-03-11
    • 2018-11-26
    • 1970-01-01
    • 2019-02-12
    • 2022-01-24
    • 2021-09-21
    • 2020-12-01
    • 1970-01-01
    相关资源
    最近更新 更多