Arrays 如何在配置单元sql中将数组转换为字符串?
我想在配置单元中将数组转换为字符串。我想收集\u设置数组值以转换为字符串,而不使用Arrays 如何在配置单元sql中将数组转换为字符串?,arrays,string,hive,concatenation,hiveql,Arrays,String,Hive,Concatenation,Hiveql,我想在配置单元中将数组转换为字符串。我想收集\u设置数组值以转换为字符串,而不使用[[“”] 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(字符串分隔符,数组)函数连接数组: select actor, concat_ws(',',collect_set(d
[[“”]
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(字符串分隔符,数组)
函数连接数组:
select actor, concat_ws(',',collect_set(date)) as grpdate from actor_table group by actor;
如果日期字段不是字符串,则将其转换为字符串:
concat_ws(',',collect_set(cast(date as string)))
如果您已经有一个数组(int)并且不想分解它以将元素类型转换为字符串,请阅读以下关于替代方法的回答:
concat_ws(',',collect_set(cast(date as string)))