我想在蜂巢中将数组转换为字符串。我想collect_set数组值转换为没有的字符串[[""]]
。
select actor, collect_set(date) as grpdate from actor_table group by actor;
这样[["2016-07-01", "2016-07-02"]]
就变成了2016-07-01, 2016-07-02
使用concat_ws(string delimiter, array<string>)
函数来连接数组:
select actor, concat_ws(',',collect_set(date)) as grpdate from actor_table group by actor;
如果日期字段不是字符串,则将其转换为字符串:
concat_ws(',',collect_set(cast(date as string)))
如果您已经有一个(int)数组并且不想爆炸以将元素类型转换为字符串,还请阅读有关其他方法的以下答案:如何在Hive中将int数组的元素连接为string
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句