作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用BigQuery从Google Analytics(分析)中查询数据。在运行之前,它给了我这个错误:
Cannot access field productQuantity on a value with type ARRAY<STRUCT<productSKU STRING, v2ProductName STRING, v2ProductCategory STRING, ...>>
我用谷歌搜索,并且我已经按照其他答案中的建议使用了UNNEST
函数。我不知道怎么了。
另外,我从Google Analytics(分析)中的不同表进行查询,并且数据按日期存储。有没有一种方法可以在不重复代码的情况下从特定时间范围进行查询?
请在下面查看我的代码:
#standardSQL
SELECT
date,
hits.transaction.transactionId,
hits.product.productQuantity
FROM
`XXX1`,
UNNEST(hits) AS hits,
UNNEST(hits.product.productQuantity) AS prod
GROUP BY
date
UNION ALL
SELECT
date,
hits.transaction.transactionId,
hits.product.productQuantity
FROM
`XXX2` UNNEST(hits) AS hits,
UNNEST(hits.product.productQuantity) AS prod
GROUP BY
date
UNION ALL
SELECT
date,
hits.transaction.transactionId,
hits.product.productQuantity
FROM
`XXX3` UNNEST(hits) AS hits,
UNNEST(hits.product.productQuantity) AS prod
GROUP BY
date
UNION ALL
SELECT
date,
hits.transaction.transactionId,
hits.product.productQuantity
FROM
`XXX4` UNNEST(hits) AS hits,
UNNEST(hits.product.productQuantity) AS prod
GROUP BY
date
UNION ALL
SELECT
date,
hits.transaction.transactionId,
hits.product.productQuantity
FROM
`XXX5` UNNEST(hits) AS hits,
UNNEST(hits.product.productQuantity) AS prod
GROUP BY
date
UNION ALL
SELECT
date,
hits.transaction.transactionId,
hits.product.productQuantity
FROM
`XXX6` UNNEST(hits) AS hits,
UNNEST(hits.product.productQuantity) AS prod
GROUP BY
date
最佳答案
无法访问类型为ARRAY>的值的字段productQuantity
您应该使用以下方法
#standardSQL
SELECT
date,
hits.transaction.transactionId,
prod.productQuantity
FROM `XXX`,
UNNEST(hits) AS hits,
UNNEST(hits.product) AS prod
productQuantity
hits.transaction.transactionId,
prod.productQuantity
#standardSQL
SELECT
date,
hits.transaction.transactionId,
prod.productQuantity
FROM `project.dataset.XXX*`,
UNNEST(hits) AS hits,
UNNEST(hits.product) AS prod
WHERE _TABLE_SUFFIX BETWEEN '1' AND '6'
关于google-analytics - 无法访问类型为ARRAY <STRUCT <productSKU STRING,v2ProductName STRING,v2ProductCategory STRING,…>>的值的字段productQuantity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56064580/
我是一名优秀的程序员,十分优秀!