如何在表中的varchar列中解析此JSON?雪花
我有一个表,其中有一列名为message_json,在该表中,我将此json存储为varchar数据类型如何在表中的varchar列中解析此JSON?雪花,json,parsing,snowflake-cloud-data-platform,Json,Parsing,Snowflake Cloud Data Platform,我有一个表,其中有一列名为message_json,在该表中,我将此json存储为varchar数据类型 { "request_id": "b53e7cc3-89b1-495b-aab0-e0dd6243b32e", "quote_id": "7a760b81-2c9c-4f20-9453-f7b72d4e06c6", "tenant_abbreviation": &quo
{
"request_id": "b53e7cc3-89b1-495b-aab0-e0dd6243b32e",
"quote_id": "7a760b81-2c9c-4f20-9453-f7b72d4e06c6",
"tenant_abbreviation": "ahs",
"tenant_id": "ee312e77-8463-44bd-ad7e-2cd4e75c9e3d",
"event_detail": {
"source": "Quote service",
"event_name": "quote_created",
"timestamp": {
"seconds": 1608236418,
"nanos": 290575000
},
"id": "7a760b81-2c9c-4f20-9453-f7b72d4e06c6"
},
"quote": {
"attribute": {
"contract.renewal": "false",
"contract.yearsOfService": "0",
"description": "xx 3X3 xx $xx DC SC",
"mktgSourceKey": "5fdc118555b95efff7d29f23",
"order.method": "eCom",
"originalSalesChannel": "",
"plan.id": "xxx",
"product.familyName": "combo",
"product.name": "xx xx COMBO $x DC SC",
"product.origin": "TX3C217D",
"property.address1": "xxx xx xx",
"property.address2": "",
"property.ageOfHome": "",
"property.city": "xxx",
"property.country": "USA",
"property.dwellingType": "1",
"property.dwellingTypeCode": "SINGLE FAMILY RESIDENCE",
"property.motherInLaw": "",
"property.sizeOfHome": "4900",
"property.state": "xxxx",
"property.unitType": "",
"property.unitValue": "",
"property.zip5": "xxxxx",
"property.zip9": "xxxxxx",
"salesChannel": "DC",
"serviceFee": "xxxx"
}
}
我试图创建一个新表,将每个key:value对分配给一个列。
我尝试过parse_jsonmessage_json,但由于某种原因,它返回的结果是这样的
{
"event_detail": {
"event_name": "xxxxxx",
"id": "77e49765-2b53-4d79-9442-8156b0bde3bc",
"source": "xxx xxx",
"timestamp": {
"nanos": 830472300,
"seconds": 1572679265
}
},
"quote_id": "77e49765-2b53-4d79-9442-8156b0bde3bc",
"request_id": "d8ad7a0a-f390-4660-8dc4-2838853d3846",
"tenant_abbreviation": "xxx",
"tenant_id": "ee312e77-8463-44bd-ad7e-2cd4e75c9e3d"
}
我还尝试了message\u json:request\u id,我得到了这个错误
函数“GET”的参数类型无效:VARCHAR16777216,VARCHAR10
非常感谢您的帮助我不知道您的情况有什么问题,但我可以通过添加一个结束括号来修复问题中的json字符串: 根据需要创建或替换临时表文本 选择'{ 请求id:b53e7cc3-89b1-495b-aab0-e0dd6243b32e, 报价单编号:7a760b81-2c9c-4f20-9453-f7b72d4e06c6, 租户名称缩写:ahs, 租户id:ee312e77-8463-44bd-ad7e-2cd4e75c9e3d, 活动详情:{ 资料来源:报价服务, 事件名称:quote\u已创建, 时间戳:{ 秒:1608236418, 奈诺:290575000 }, 识别号:7a760b81-2c9c-4f20-9453-f7b72d4e06c6 }, 引述:{ 属性:{ 合同续签:假, 合同有效期:0年, 说明:xx 3X3 xx$xx DC SC, mktgSourceKey:5fdc118555b95efff7d29f23, 方法:eCom, 原始语音频道:, 计划编号:xxx, product.familyName:combo, 产品名称:xx xx组合$x DC SC, 产品来源:TX3C217D, property.address 1:xxx xx, property.address2:, property.ageOfHome:, 房地产。城市:xxx, 国家:美国, property.Residenting类型:1, property.ResidentingTypeCode:单户住宅, property.motherInLaw:, property.sizeOfHome:4900, property.state:xxxx, property.unitType:, property.unitValue:, property.zip5:xxxxx, property.zip9:xxxxxx, 销售频道:华盛顿, 服务费:xxxx } } }"投入,; 选择parse_jsoninput:request_id 从文本 -b53e7cc3-89b1-495b-aab0-e0dd6243b32e 它甚至还带着据称缺失的部件回来: 选择parse_jsoninput:quote.attribute['property.address1'] 从文本 -xxx xx xx
非常感谢。这为我完成基础工作奠定了基础。你是怎么知道使用这种语法的?我已经看过文档了。我没有看到quote.attribute['property.address1']语法。