简体   繁体   English

BigQuery 中的 Unnest 导致“数组”错误

[英]Unnest in BigQuery leading to “Array” error

I am taking over the work of a former colleague and try to build on top of it.我正在接手一位前同事的工作,并试图在此基础上再接再厉。 His work led to unnesting a parent categories, and I am trying to achieve the same for another category.他的工作导致取消嵌套父类别,我正在尝试为另一个类别实现相同的目标。 My additional Unnesting is, however, leading to an error due to Array structure - which is why I want to unnest in the first play right?但是,由于 Array 结构,我的额外取消嵌套会导致错误 - 这就是为什么我想在第一场比赛中取消嵌套,对吧? :( :(

Please see attached image请看附图图片

(the Error code is: "Cannot access field refund_line_items on a value with type ARRAY>, id INT64, processed_at TIMESTAMP, ...>> at [19:16]") (错误代码是:“无法访问类型为 ARRAY>、id INT64、processed_at TIMESTAMP、...>> at [19:16] 的值的字段refund_line_items”)

Any help will be much appreciated!任何帮助都感激不尽!

If I understand your table schema correctly.如果我正确理解您的表架构。 refunds is an array, so you need to unnest the array field then access its struct field inside, like refunds是一个数组,因此您需要取消嵌套数组字段,然后访问其内部的结构字段,例如

SELECT refund.refund_line_items
FROM orders
JOIN UNNEST(refunds) refund

See more on: Querying STRUCT elements in an ARRAY查看更多信息: 查询 ARRAY 中的 STRUCT 元素

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM