【问题标题】:How to cast array<int> to string in hive?如何将 array<int> 转换为 hive 中的字符串?
【发布时间】:2017-06-13 16:58:11
【问题描述】:

我有一列 array&lt;bigint&gt; 类型的列(例如值 [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&lt;bigint&gt; 转换为array&lt;string&gt;

【问题讨论】:

标签: hive hiveql


【解决方案1】:

试试这个:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-07
    • 1970-01-01
    • 1970-01-01
    • 2015-11-12
    • 2018-05-08
    • 1970-01-01
    相关资源
    最近更新 更多