我在 "content "列里有一个json,格式如下。
{ "identifier": [
{
"type": {
"coding": [
{
"code": "MRN",
}
]
},
"value": "181"
},
{
"type": {
"coding": [
{
"code": "PID",
}
]
},
"value": "5d3669b0"
},
{
"type": {
"coding": [
{
"code": "IPN",
}
]
},
"value": "41806"
}
]}
我必须运行一个hive查询来获取代码的 "值",它等于 "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是随机创建的,位置并不总是固定的。
给予[ * ]以避免给予位置。
选择 get_json_object(content,'$.identifier[]。].value')as Mrn from Doctor where get_json_object(content,'$.identifer[].type.coding.code')如'%MRN%'