1.取得非group by 字段
select COLLECT_LIST(event) , uuid from stat_event group by uuid;
2.得到事件流(自定义事件处理)
select cid, uuid, account, concat_ws(',', COLLECT_LIST(cast (event AS string) ) ), concat_ws(',', COLLECT_LIST(cast (timestamp AS string) ) ) from stat_event where year = 2015 and month = 1 and day = 5 group by cid, uuid, account;
总结:
COLLECT_LIST(event):会得到一个 完整的 事件序列(未排序的)
COLLECT_SET(event):会得到一个 去重的 事件序列 (未排序的)
concat_ws(',' , COLLECT_LIST(cast (event AS string) ) ) :事件按照逗号分隔,组成一个事件流字符串
本文介绍了如何使用SQL中的聚合函数COLLECT_LIST和COLLECT_SET来收集并处理特定字段的数据,包括获取非分组字段的完整事件序列及去重事件序列,并通过concat_ws函数将事件序列转换为字符串形式。
2385

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



