如何在Hive中将int数组的元素连接为字符串 [英] How to concatenate the elements of int array to string in Hive
本文介绍了如何在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屋!
查看全文