如何在hive sql中将数组转换为字符串?

Bet*_*lee 21 arrays string hive hiveql

我想在hive中将数组转换为字符串.我想collect_set数组值转换为字符串而不用[[""]].

select actor, collect_set(date) as grpdate from actor_table group by actor;
Run Code Online (Sandbox Code Playgroud)

[["2016-07-01", "2016-07-02"]]将成为2016-07-01, 2016-07-02

lef*_*oin 38

使用concat_ws(string delimiter, array<string>)函数连接数组:

select actor, concat_ws(',',collect_set(date)) as grpdate from actor_table group by actor;
Run Code Online (Sandbox Code Playgroud)

如果日期字段不是字符串,则将其转换为字符串:

concat_ws(',',collect_set(cast(date as string)))
Run Code Online (Sandbox Code Playgroud)