用于从Json数组获取Json对象的配置单元Sql查询
我在“内容”列中有一个json,格式如下:用于从Json数组获取Json对象的配置单元Sql查询,json,hive,hiveql,Json,Hive,Hiveql,我在“内容”列中有一个json,格式如下: { "identifier": [ { "type": { "coding": [ { "code": "MRN", } ] }, "value": "181" }, { "type":
{ "identifier": [
{
"type": {
"coding": [
{
"code": "MRN",
}
]
},
"value": "181"
},
{
"type": {
"coding": [
{
"code": "PID",
}
]
},
"value": "5d3669b0"
},
{
"type": {
"coding": [
{
"code": "IPN",
}
]
},
"value": "41806"
}
]}
我必须运行配置单元查询来获取代码的“值”,该值等于“MRN”。
我编写了以下查询,但它没有给出预期的值:
select get_json_object(content,'$.identifier.value')as Mrn from Doctor where get_json_object(content,'$.identifier.type.coding.code') like '%MRN%'
我不想给出特定的数组位置,如:
select get_json_object(content,'$.identifier[0].value')as Mrn from Doctor where get_json_object(content,'$.identifier[0].type.coding.code') like '%MRN%'
因为json是随机创建的,位置并不总是固定的。Give[*]以避免给出位置
select get_json_object(content,'$.identifier[*].value')as Mrn from Doctor where get_json_object(content,'$.identifier[*].type.coding.code') like '%MRN%'
有人能帮忙吗?