我有一个json喜欢:
{"key": [1,2], "group": 1}
{"key": [1,3], "group": 2}
我将我的json加载到hive中,我想在数据库中的另一个表上使用这些键进行内连接。
结果应该类似
Group Value
1 "this is some value corresponding to 1 in another table"
1 "this is some value corresponding to 2"
2 "this is some value corresponding to 1"
2 "this is some value corresponding to 3"
这是一个基本的内置功能,还是我需要有创意?
答案 0 :(得分:0)
select kg.group,k.value
from my_json_table jt
lateral view json_tuple(jt.my_json_column,'key','group') kg as key,group
lateral view explode (split(regexp_extract(kg.key,'\\[(.*)\\]',1),',')) k as value
;
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF