2017-06-13 209 views
0

我有一个类型array<bigint>(说价值[1,2,3,4])的列,我想将其转换为string(说“1,2,3,4”),我该怎么做?如何将阵列<int>投射到蜂巢中的字符串?

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

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

有没有办法投array<bigint>array<string>

+0

可能是你的答案就在这里 - https://stackoverflow.com/questions/40977674/how-to-concatenate-the-elemets-of-int-array-to- string-in-hive – aksss

+0

[如何将int数组的元素连接到Hive中的字符串](https://stackoverflow.com/questions/40977674/how-to-concatenate-the-elemets-of-int-阵列到字符串中-蜂房) – aksss

回答

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