[英]Unnesting Multiple Nested Fields Deep in BigQuery
我試圖在 BigQuery 中使用標准 SQL 方言來取消嵌套 changelog.history.items 重復記錄(以綠色標出)以訪問嵌套項目表(以藍色標出)中的行。 父記錄“變更日志”(以紅色標出)不是重復記錄,因此我在弄清楚要取消嵌套的內容時遇到問題。
嘗試取消嵌套 changelog.histories 或 changelog.histories.items 的查詢會導致以下錯誤。
SELECT changelog.histories.items.to
FROM jirasparta_database.jira_issues,
unnest(changelog.histories)
錯誤:無法訪問類型為 ARRAY、...> 的值上的字段項,項 ARRAYto STRING、字段 STRING、字段類型 STRING、...>>、...>> 在 [1:28]
#standardSQL
SELECT item.to
FROM jirasparta_database.jira_issues,
UNNEST(changelog.histories) history, UNNEST(history.items) item
基本上,您必須展平 STRUCT 和 ARRAY 值。 您可以查看此文檔以獲取更多詳細信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.