hive如何实现行列转换
1. 行转列 原始数据: name constellation blood_type 孙悟空 白羊座 A 大海 射手座 A 宋宋 白羊座 B 猪八戒 白羊座 A 凤姐 射手座 A 现在需要把星座和血型一样的人归类到一起。结果如下: 射手座,A 大海 | 凤姐 白羊座,A 孙悟空 | 猪八戒 白羊座,B 宋宋 # vim person.txt 孙悟空 , 白羊座 , A 大海 , 射手座 , A 宋宋 , 白羊座 , B 猪八戒 , 白羊座 , A 凤姐 , 射手座 , A # 创建hive表 hive > create table person_info ( name string , constellation string , blood_type string ) row format delimited fields terminated by "," ; # 加载数据 hive > load data local inpath "/root/person.txt" into table person_info ; # 转换sql hive > select t . base , concat_ws ( '|' , collect_set ( t . name ) ) from ( select name , concat ( constellation , "," ,