一系列的union all产生一个键值对列表,我想用它来构建一个Map。
所需的功能如下:
select id1, id2, map(collect_list(col)) as measurements
from
(
select id1, id2, "height" as col
union all
select id1, id2, count(*) as col from table1
union all
select id1, id2, "weight" as col
union all
select id1, id2, count(*) as col from table2
)
正确的方法是什么?
我希望得到的结果是:
id1 id2 measurements
1 10 {"height": 10, "weight": 20}
2 20 {"height": 10, "weight": 20}
1条答案
按热度按时间wecizke31#
你的要求不是很清楚,但看起来你需要这样的东西
我没有运行它,但它应该工作。