Databricks SQL:从静态表查询原始“JSON”字符串时仅返回 NULL 值

问题描述 投票:0回答:1

我正在尝试从我创建的以下 JSON 文件//自定义表中提取数据元素。数据是匿名的,来自 HIE FHIR 网站(来源:https://www.hl7.org/fhir/patent-example-f001-pieter.json.html

CREATE TABLE hl7_pat AS SELECT
'
{
    "resourceType": "Patient",
    "id": "f001",
    "text": {
        "status": "generated"
    },
    "identifier": [
        {
            "use": "usual",
            "system": "urn:oid:2.16.840.1.113883.2.4.6.3",
            "value": "738472983"
        },
        {
            "use": "usual",
            "system": "urn:oid:2.16.840.1.113883.2.4.6.3"
        }
    ],
    "active": true,
    "name": [
        {
            "use": "usual",
            "family": "van de Heuvel",
            "given": [
                "Pieter"
            ],
            "suffix": [
                "MSc"
            ]
        }
    ],
    "telecom": [
        {
            "system": "phone",
            "value": "0648352638",
            "use": "mobile"
        },
        {
            "system": "email",
            "value": "[email protected]",
            "use": "home"
        }
    ],
    "gender": "male",
    "birthDate": "1944-11-17",
    "deceasedBoolean": false,
    "address": [
        {
            "use": "home",
            "line": [
                "Van Egmondkade 23"
            ],
            "city": "Amsterdam",
            "postalCode": "1024 RJ",
            "country": "NLD"
        }
    ],
    "maritalStatus": {
        "coding": [
            {
                "system": "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus",
                "code": "M",
                "display": "Married"
            }
        ],
        "text": "Getrouwd"
    },
    "multipleBirthBoolean": true,
    "contact": [
        {
            "relationship": [
                {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v2-0131",
                            "code": "C"
                        }
                    ]
                }
            ],
            "name": {
                "use": "usual",
                "family": "Abels",
                "given": [
                    "Sarah"
                ]
            },
            "telecom": [
                {
                    "system": "phone",
                    "value": "0690383372",
                    "use": "mobile"
                }
            ]
        }
    ],
    "communication": [
        {
            "language": {
                "coding": [
                    {
                        "system": "urn:ietf:bcp:47",
                        "code": "nl",
                        "display": "Dutch"
                    }
                ],
                "text": "Nederlands"
            },
            "preferred": true
        }
    ],
    "managingOrganization": {
        "reference": "Organization/f001",
        "display": "Burgers University Medical Centre"
    }
}
' as raw;

我正在使用以下语法来尝试从中获取数据。

从 hl7_pat 中选择原始:资源类型;

上面的查询应该简单地返回“Patient”,但它返回 NULL。关于为什么这不起作用的任何建议?

我尝试运行: SELECT raw:resourceType FROM hl7_pat;但得到了 NULL 值。我期待见到“病人”

EDIT1:添加刚刚运行“SELECT * FROM ..”的屏幕截图 enter image description here

json databricks hl7-fhir aws-databricks
1个回答
0
投票

它正在按预期工作。

您还可以使用

from_json
函数从 json 对象中提取属性。

© www.soinside.com 2019 - 2024. All rights reserved.