如何将数组<int>转换为配置单元中的字符串?

问题描述 投票:0回答:2

我有一个类型为

array<bigint>
的列(例如值 [1,2,3,4]),我想将其转换为
string
(例如“1,2,3,4”),如何才能我这样做?

我尝试过

concat_ws(',' arr)
,但它抱怨

Argument 2 of function CONCAT_WS must be "string or array<string>", but "array<bigint>" was found."

有没有办法将

array<bigint>
转换为
array<string>

hive hiveql
2个回答
0
投票

试试这个:

select xx,concat_ws(',',collect_set(cast(element as string))) as arrystr
from table
lateral view explode(arr) b as element
group by xx

0
投票

试试这个:

select
    regexp_replace(string_with_brackets,'\\[|\\]','') as final_str
from
(
    select 
    transform(array_of_int) using '/bin/cat' as (string_with_brackets)
)
© www.soinside.com 2019 - 2024. All rights reserved.