我想在hive中将数组转换为字符串。我想将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
答案 0 :(得分:32)
使用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)))