BigQuery:在标准SQL中使用重复的数组STRUCT字段加入联接吗?

BigQuery:在标准SQL中使用重复的数组STRUCT字段加入联接吗?,第1张

BigQuery:在标准SQL中使用重复的/数组STRUCT字段加入联接吗?

另一种选择是做CROSS JOIN而不是LEFT JOIN

#standardSQLWITH Orders AS (  SELECt 1 AS __oid__, ARRAY[STRUCT(STRUCT(1 AS id, "default" AS ns) AS key), STRUCT(STRUCT(2 AS id, "default" AS ns) AS key)] AS items UNIOn ALL   SELECT 2 AS __oid__, ARRAY[STRUCT(STRUCT(3 AS id, "default" AS ns) AS key), STRUCT(STRUCT(4 AS id, "default" AS ns) AS key)] AS items UNIOn ALL   SELECT 3 AS __oid__, ARRAY[STRUCT(STRUCT(5 AS id, "default" AS ns) AS key), STRUCT(STRUCT(6 AS id, "default" AS ns) AS key)] AS items),Items AS (  SELECT STRUCT(1 AS id, "default" AS ns) AS key, "#1.1" AS title UNIOn ALL  SELECT STRUCT(2 AS id, "default" AS ns) AS key, "#1.2" AS title UNIOn ALL  SELECT STRUCT(3 AS id, "default" AS ns) AS key, "#1.3" AS title UNIOn ALL  SELECT STRUCT(4 AS id, "default" AS ns) AS key, "#1.4" AS title UNIOn ALL  SELECT STRUCT(5 AS id, "default" AS ns) AS key, "#1.5" AS title UNIOn ALL  SELECT STRUCT(6 AS id, "default" AS ns) AS key, "#1.6" AS title)SELECT   __oid__  ,ARRAY_AGG(Order_items) AS itemsFROM OrdersCROSS JOIN(  SELECt     key    ,title  FROM Items) Order_itemsWHERe Order_items.key.id IN (SELECt item.key.id FROM UNNEST(items) AS item)GROUP BY __oid__


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5144174.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-17
下一篇 2022-11-18

发表评论

登录后才能评论

评论列表(0条)

保存