hive聚合函数参见:https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-Built-inAggregateFunctions
(1)collect_set(col)函数用于合并某列的值,去重后返回一个数组。假设user_course表的数据如下:
user_id course score
a1001 english 99
a1001 chinese 90
select collect_set(course) as courses from user_course group_by user_id;
返回的结果位[english, chinese]
注意的是,collect_set必须与group by 语句共同使用。
(2)explode(array) 用于将一个数组拆分成多行。
(3)concat_ws(separator, elements)将elements用separator为分隔符连接起来