我想把一个字符串转换成十六进制,例如:there is a string as '[1,2,3,4,5]' ,我想把它转换成十六进制,输出应该是字符串,如下所示: '[31,32,33,35,35]' 使用hiveql
'[1,2,3,4,5]'
'[31,32,33,35,35]'
5sxhfpxr1#
删除前后方括号,拆分为数组,分解,转换为十六进制,然后再次收集数组,最后连接它:
with data as ( select '[1,2,3,4,5]' str ) select '['||concat_ws(',',collect_list(hex(e.a)))||']' as result from data d lateral view explode(split(regexp_replace(str,'\\[|\\]',''),',')) e as a
结果
[31,32,33,34,35]
1条答案
按热度按时间5sxhfpxr1#
删除前后方括号,拆分为数组,分解,转换为十六进制,然后再次收集数组,最后连接它:
结果