【问题标题】:Convert array<string> to string [duplicate]将数组<字符串>转换为字符串[重复]
【发布时间】:2020-10-01 11:04:32
【问题描述】:

我有一个 hive 字符串数组,我想将其转换为字符串。 Hive 版本为 1.2.1000.2.6.1.0-129。

create table a (arr array<string>);

create table b (str array<string>);

insert into table b
select * from a;

我试过了:

concat_ws(',',collect_set(cast(arr as string))

collect_set(cast(arr as string))

cast(arr as string)

【问题讨论】:

  • 谢谢,但不适合我
  • 具体出了什么问题?

标签: sql arrays string hive hiveql


【解决方案1】:

concat_ws() 函数(用分隔符连接)将数组元素连接成用指定分隔符分隔的字符串(本例中为逗号):

concat_ws(',',arr) as result

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-05
    • 1970-01-01
    • 1970-01-01
    • 2016-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多