在Hive中使用Hive sql实现表 数据的行转列、列转行:
原始数据:
行转列:
select ss.id,ss.name,s1 from test_sql ss
lateral view explode(split(ss.address,',')) aa as s1
列转行:
select sss.id,sss.name,concat_ws(',',collect_set(sss.s1)) from
(
select ss.id,ss.name,s1 from test_sql ss
lateral view explode(split(ss.address,',')) aa as s1
)sss group by sss.id,sss.name
order by sss.id
效果: