Hive行转列、列转行

来源:互联网 发布:网络宣传要会什么 编辑:程序博客网 时间:2024/05/21 05:07
---- concat_ws(',','str1','str2','str3')  ---  'str1,str2,str3' 
---concat_ws 将字符串联起来用','隔开 

列转行:

select col1,col2,concat_ws(',',collect_list(col3)) as col3 from table group by col1,col2

行转列:

select col1,col2,name from tableName lateral view explode(col3) col3 as name
原创粉丝点击