Hive中有两种用于列转行的函数collect_list和collect_set
他们的区别是collect_list获取的结果是全部的可重复的,collect_set的结果是去重之后不重复的。
可以联想到list和set集合的特性记忆,list是有序可重复的,set是无序不可重复的。
例如:
students中有学生id和课程字段
select id,collect_list(course) from students group by id;
select id,collect_set(course) from students group by id;