如何在hive中将数组<int>转换为字符串?

时间:2017-06-13 16:58:12

标签: hive hiveql

我有一个类型为array<bigint>的列(比如值[1,2,3,4]),我希望将其转换为string(例如&#34; 1,2 ,3,4&#34;),我该怎么做?

我试过concat_ws(',' arr),但它抱怨

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

有没有办法将array<bigint>投放到array<string>

1 个答案:

答案 0 :(得分: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