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。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Apache Hive
Apache Hive的相关知识,包括简单介绍,环境配置,和使用简介
mysql Hive SQL