如何在 Hive 中将 int 数组的元素连接到字符串 [英] How to concatenate the elements of int array to string in Hive

查看:32
本文介绍了如何在 Hive 中将 int 数组的元素连接到字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 int 数组的元素连接到 .

I'm trying to concatenate the element of int array to one string in hive.

函数 concat_ws 仅适用于字符串数组,所以我尝试了 cast(my_int_array as string) 但它不起作用.

The function concat_ws works only for string arrays, so I tried cast(my_int_array as string) but it's not working.

有什么建议吗?

推荐答案

尝试使用/bin/cat 进行转换:

Try to transform using /bin/cat:

from mytable select transform(my_int_array) using '/bin/cat' as (my_int_array);

第二个选项是改变表格并替换分隔符:

Second option is to alter table and replace delimiters:

1) ALTER TABLE mytable  CHANGE COLUMN my_int_array = my_int_array_string string;
2) SELECT REPLACE(my_int_array_string, '\002', ', ') FROM mytable;

这篇关于如何在 Hive 中将 int 数组的元素连接到字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆