Hive 如何在配置单元中分解贴图数组
考虑一个具有以下结构的表Hive 如何在配置单元中分解贴图数组,hive,hiveql,Hive,Hiveql,考虑一个具有以下结构的表my_table: >> describe my_table id bigint info_detail map<bigint,array<string>> 如何分解细节,因此结果如下所示: info_id detail 112344 "something about 112344" 112344 "other things" 342302 "somethi
my_table
:
>> describe my_table
id bigint
info_detail map<bigint,array<string>>
如何分解细节
,因此结果如下所示:
info_id detail
112344 "something about 112344"
112344 "other things"
342302 "something about 342302"
您必须将
分解
两次,一次在映射
列上,然后在其中生成的数组
上
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
您应该能够在分解贴图后分解数组,如下所示
select info_id, d from (
select explode(info_detail) as (info_id, detail)
from my_table
) t lateral view explode(detail) detailexploded as d;
编译语句时,
Error:FAILED:SemanticException[Error 10081]:在SELECT子句之外不支持UDTF,在表达式中也不支持UDTF,而不是在数组中进行分解,因此在第一次分解之后添加UDTF似乎有效:横向视图分解(细节)按细节进行测试这是一种干净的解决方案
select info_id, d from (
select explode(info_detail) as (info_id, detail)
from my_table
) t lateral view explode(detail) detailexploded as d;