考虑具有以下结构的表my_table
:
>> describe my_table
id bigint
info_detail map<bigint,array<string>>
如果爆炸info_detail
,我将得到数组:
>> select explode(info_detail) as (info_id, detail)
from my_table
info_id detail
112344 ["something about 112344", "other things"]
342302 ["something about 342302"]
也如何爆炸detail
,所以结果看起来像这样:
info_id detail
112344 "something about 112344"
112344 "other things"
342302 "something about 342302"
答案 0 :(得分:1)
按如下所示分解地图后,应该可以分解数组
select info_id, d from (
select explode(info_detail) as (info_id, detail)
from my_table
) t lateral view explode(detail) detailexploded as d;
答案 1 :(得分:-1)
您必须两次explode
,一次在map
列上,然后在其中的结果array
上。
select tbl.info_id,tbl1.details
from my_table m
lateral view explode(info_detail) tbl as info_id,detail
lateral view explode(detail) tbl1 as details