赞
踩
执行结果如下:
附脚本:
- with t as (
- select
- concat(
- '{'
- ,'"key1":"','data1','"'
- ,',','"key2":"','data2','"'
- ,',','"key3":"','data3','"'
- ,'}'
-
- ) js
- ,concat(
- '{'
- ,'"key1":"','data1','"'
- ,',','"key2": ',
- '{'
- ,'"key1":"','data1','"'
- ,',','"key2":"','data2','"'
- ,',','"key3":"','data3','"'
- ,'}'
- ,' '
- ,',','"key3":"','data3','"'
- ,'}'
-
- ) jl -- json list
-
- )
- select
- js
- ,get_json_object(js,'$.key1') as data1
- ,get_json_object(js,'$.key2') as data2
- ,get_json_object(js,'$.key3') as data3
- ,jl
- ,get_json_object(jl,'$.key2') as data22
- from t
另外这里有个注意点,concat在连接字段时,如果有一个为null,那么整个concat的结果全部为null,需要特别注意一下.
详见Hive常用技巧记录_yipiantian的博客-CSDN博客 中的第一部分第6点
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。