Hive中实现group concat功能(不用udf)


Hive中实现group concat功能(不用udf)
 
Sql代码  
hive> desc t;  
OK  
id      string  
str     string  
Time taken: 0.249 seconds  
hive> select * from t;  
OK  
1       A  
1       B  
2       C  
2       D  
Time taken: 0.209 seconds  
 
在Hive0.9中,可用:
 
SELECT id,
concat_ws('|', collect_set(str)) 
FROM t  
GROUP BY id;
得到结果:
 
1 A|B
2 C|D
 
但在hive0.7中不容易实现,concat_ws函数不支持Array。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM