[英]How to rearrange/reorder nested repeated column in Bigquery when UNION tables
我有两个具有相似架构但顺序不同的 Bigquery 表
当使用下面的查询联合这两个表时,
select id, timestamp, products, count_total_visit, count_unique_session from table1
union all
select id, timestamp, products, count_total_visit, count_unique_session from table2
这是我得到的错误
UNION ALL 中的第 3 列具有不兼容的类型:ARRAY<STRUCT<name STRING, group STRING, ...>>, ARRAY<STRUCT<name STRING, group STRING, ...>> at [...]
如何通过嵌套重复字段重新排列模式的顺序,以便通过保持模式格式与源表相同来合并 2 个表?
下面会做的伎俩
select id, timestamp, products, count_total_visit, count_unique_session from table1
union all
select * replace (array(
select as struct * replace (array(
select as struct paiment_method, count_total_trx, sum_total_gbv, sum_total_revenue
from product.details
) as details
)
from t.products product
) as products)
from table2 t
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.