1.collect_list 多行转一行,有序不去重
数据
select 123 uid,'a' name, int(1) type
from t
union all
select 123 uid,'b' name, int(2) type
from t
union all
select 123 uid,'c' name, int(3) type
from t
union all
select 123 uid,'d' name, int(4) type
from t
union all
select 122 uid,'a' name, int(1) type
from t
union all
select 122 uid,'b' name, int(2) type
from t
union all
select 122 uid,'c' name, int(3) type
from t
union all
select 124 uid,'a' name, int(1) type
from t
union all
select 124 uid,'b' name, int(3) type
from t
表

TEMP t= select uid,name from temp_2019123102 distribute by uid sort by type
OUTPUT select uid,concat_ws('->',collect_list(name)) names from t group by uid

本文介绍了Hive SQL中的collect_list和collect_set函数,用于将多行数据转换为一行。collect_list保留顺序但可能包含重复值,而collect_set则会去除重复值但顺序不保证。
最低0.47元/天 解锁文章
1281

被折叠的 条评论
为什么被折叠?



