Hive常见面试题

1、行列转换

行转列:collect_set/collect_list

列转行:

select t1.*, t2.col3_new
from
(
select 'a' as col1, 'b' as col2, '1,2,3' as col3
union all
select 'c' as col1, 'd' as col2, '4,5,6' as col3
)t1
lateral view explode(split(col3,','))t2 as col3_new; -- 主要是最后一行的写法

posted @ 2021-04-06 10:35  再见傅里叶  阅读(88)  评论(0编辑  收藏  举报