简体   繁体   English

从雪花中的嵌套变体/JSON 列中提取数据

[英]Extracting data from a nested variant/JSON column in snowflake

Below is the data I have from a Json file which is loaded into snowflake variant table and I want to extract 'Mike Robinson' from the value {\"objCode\":\"USER\",\"name\":\"Mike Robinson\",\"ID\":\"5e4edc9400fbf45c6a67786fe0b62466\"} , for the column DE:WSP PRG GPM Partner from the below example.下面是我从加载到雪花变量表中的 Json 文件中获得的数据,我想从值{\"objCode\":\"USER\",\"name\":\"Mike Robinson\",\"ID\":\"5e4edc9400fbf45c6a67786fe0b62466\"} ,用于以下示例中的列DE:WSP PRG GPM Partner

{
      "ID": "5e13939f00e62030bc40ae3a243f538c",
      "auditTypes": [],
      "categoryID": "6037d132005cf57b209d13eef407a03b",
      "customerID": "76bf18dd792b9b9ce0530a093a0a1933",
      "description": "Continue to grow Wise in current markets and expand public library opportunities in new markets.",
      "enteredByID": null,
      "entryDate": "2020-01-06T15:07:59:367-0500",
      "etl_load_ts": "2021-04-22_14:41:35:828",
      "extRefID": null,
      "hasDocuments": false,
      "hasMessages": false,
      "hasNotes": false,
      "isActive": true,
      "lastUpdateDate": "2021-04-15T11:32:21:311-0400",
      "lastUpdatedByID": "5e4edc9400fbf45c6a67786fe0b62466",
      "name": "Program: OCLC Wise (SB)",
      "objCode": "PRGM",
      "ownerID": "5e4edac200f823591158b896c670f51b",
      "parameterValues": {
        "DE:Program Show on WSP": "Yes",
        "DE:WSP PRG Executive Status Summary": "Overall health is YELLOW. For US libraries we had a key breakthrough on 2/17. After months of work with Linked In, we have achieved interoperability with Lynda.com. Many public libraries provide access to training via Lynda.com to benefit their patrons.",
        "DE:WSP PRG Financial Partner": "{\"objCode\":\"USER\",\"name\":\"Chad Beuck\",\"ID\":\"5e4eda6500f75fa86187f5c0b6dea9a2\"}",
        "DE:WSP PRG GPM Partner": "{\"objCode\":\"USER\",\"name\":\"Mike Robinson\",\"ID\":\"5e4edc9400fbf45c6a67786fe0b62466\"}",
        "DE:WSP PRG KD-1 Reason": "N/A",
        "DE:WSP PRG KD-2 Reason": "N/A",
        "DE:WSP PRG Key Decision Date Approved 1": "2021-02-01",
        "DE:WSP PRG Key Decision Date Approved 2": "2021-02-01",
        "DE:WSP PRG Key Decision Description 1": "N/A",
        "DE:WSP PRG Key Decision Description 2": "N/A",
        "DE:WSP PRG Key Decision ID 1": "0000",
        "DE:WSP PRG Key Decision ID 2": "N/A",
        "DE:WSP PRG Key Decision Owner 1": "N/A",
        "DE:WSP PRG Key Decision Owner 2": "N/A",
        "DE:WSP PRG Key Dependencies 1": "N/A",
        "DE:WSP PRG Key Dependencies 2": "N/A",
        "DE:WSP PRG Key R/I Description 1": "Recently heightened srutiny of security and privacy practices is resulting in project impacts for EMEA based projects.",
        "DE:WSP PRG Key R/I Description 2": "---",
        "DE:WSP PRG Key R/I Impact 1": "2",
        "DE:WSP PRG Key R/I Impact 2": "-",
        "DE:WSP PRG Key R/I Impact to Cost 1": "Indirect",
        "DE:WSP PRG Key R/I Impact to Cost 2": "---",
        "DE:WSP PRG Key R/I Impact to Sched 1": "Yes",
        "DE:WSP PRG Key R/I Impact to Sched 2": "---",
        "DE:WSP PRG Key R/I Probability 1": "-",
        "DE:WSP PRG Key R/I Probability 2": "-",
        "DE:WSP PRG Key Risk/Issue 1": "Issue",
        "DE:WSP PRG Key Risk/Issue 2": "---",
        "DE:WSP PRG Key Risk/Issue Choice 1": "Risk",
        "DE:WSP PRG Key Risk/Issue Choice 2": "Issue",
        "DE:WSP PRG Overall Health": "Yellow",
        "DE:WSP PRG Primary Business Value": "Provide a comprehensive view of all Wise work activities and understand their impact to the resource portfolio. Assure effective communications, coordination across workstreams in order to prevent delivery delays/failures.",
        "DE:WSP PRG Program Code #": "N/A",
        "DE:WSP PRG Program Sponsor": "{\"objCode\":\"USER\",\"name\":\"Scott Livingston\",\"ID\":\"5e4edbd300fa28183f47c65b9641d7cb\"}",
        "DE:WSP PRG Program Turned Red": "2021-02-01",
        "DE:WSP PRG Target For Green": "2021-03-03",
        "DE:WSP PRG Upcoming MS-1 Date": "2021-03-15",
        "DE:WSP PRG Upcoming MS-2 Date": "2021-02-26",
        "DE:WSP PRG Upcoming MS-3 Date": "2021-03-15",
        "DE:WSP PRG Upcoming MS-4 Date": "2021-03-22",
        "DE:WSP PRG Upcoming Milestone 1": "Fayetteville Go Live",
        "DE:WSP PRG Upcoming Milestone 2": "3475 - Path to GREEN Realized",
        "DE:WSP PRG Upcoming Milestone 3": "N/A",
        "DE:WSP PRG Upcoming Milestone 4": "N/A"
      },
      "portfolioID": "5bfc22ed00b20b189229e8201f3742b6",
      "securityRootID": "5e13939f00e62030bc40ae3a243f538c",
      "securityRootObjCode": "PRGM"
    },

parse_json(parse_json(val):"parameterValues"."DE:WSP PRG GPM Partner"):name returns "Mike Robinson": parse_json(parse_json(val):"parameterValues"."DE:WSP PRG GPM Partner"):name返回 "Mike Robinson":

with data as (
select 
$$
{
      "ID": "5e13939f00e62030bc40ae3a243f538c",
      "auditTypes": [],
      "categoryID": "6037d132005cf57b209d13eef407a03b",
      "customerID": "76bf18dd792b9b9ce0530a093a0a1933",
      "description": "Continue to grow Wise in current markets and expand public library opportunities in new markets.",
      "enteredByID": null,
      "entryDate": "2020-01-06T15:07:59:367-0500",
      "etl_load_ts": "2021-04-22_14:41:35:828",
      "extRefID": null,
      "hasDocuments": false,
      "hasMessages": false,
      "hasNotes": false,
      "isActive": true,
      "lastUpdateDate": "2021-04-15T11:32:21:311-0400",
      "lastUpdatedByID": "5e4edc9400fbf45c6a67786fe0b62466",
      "name": "Program: OCLC Wise (SB)",
      "objCode": "PRGM",
      "ownerID": "5e4edac200f823591158b896c670f51b",
      "parameterValues": {
        "DE:Program Show on WSP": "Yes",
        "DE:WSP PRG Executive Status Summary": "Overall health is YELLOW. For US libraries we had a key breakthrough on 2/17. After months of work with Linked In, we have achieved interoperability with Lynda.com. Many public libraries provide access to training via Lynda.com to benefit their patrons.",
        "DE:WSP PRG Financial Partner": "{\"objCode\":\"USER\",\"name\":\"Chad Beuck\",\"ID\":\"5e4eda6500f75fa86187f5c0b6dea9a2\"}",
        "DE:WSP PRG GPM Partner": "{\"objCode\":\"USER\",\"name\":\"Mike Robinson\",\"ID\":\"5e4edc9400fbf45c6a67786fe0b62466\"}",
        "DE:WSP PRG KD-1 Reason": "N/A",
        "DE:WSP PRG KD-2 Reason": "N/A",
        "DE:WSP PRG Key Decision Date Approved 1": "2021-02-01",
        "DE:WSP PRG Key Decision Date Approved 2": "2021-02-01",
        "DE:WSP PRG Key Decision Description 1": "N/A",
        "DE:WSP PRG Key Decision Description 2": "N/A",
        "DE:WSP PRG Key Decision ID 1": "0000",
        "DE:WSP PRG Key Decision ID 2": "N/A",
        "DE:WSP PRG Key Decision Owner 1": "N/A",
        "DE:WSP PRG Key Decision Owner 2": "N/A",
        "DE:WSP PRG Key Dependencies 1": "N/A",
        "DE:WSP PRG Key Dependencies 2": "N/A",
        "DE:WSP PRG Key R/I Description 1": "Recently heightened srutiny of security and privacy practices is resulting in project impacts for EMEA based projects.",
        "DE:WSP PRG Key R/I Description 2": "---",
        "DE:WSP PRG Key R/I Impact 1": "2",
        "DE:WSP PRG Key R/I Impact 2": "-",
        "DE:WSP PRG Key R/I Impact to Cost 1": "Indirect",
        "DE:WSP PRG Key R/I Impact to Cost 2": "---",
        "DE:WSP PRG Key R/I Impact to Sched 1": "Yes",
        "DE:WSP PRG Key R/I Impact to Sched 2": "---",
        "DE:WSP PRG Key R/I Probability 1": "-",
        "DE:WSP PRG Key R/I Probability 2": "-",
        "DE:WSP PRG Key Risk/Issue 1": "Issue",
        "DE:WSP PRG Key Risk/Issue 2": "---",
        "DE:WSP PRG Key Risk/Issue Choice 1": "Risk",
        "DE:WSP PRG Key Risk/Issue Choice 2": "Issue",
        "DE:WSP PRG Overall Health": "Yellow",
        "DE:WSP PRG Primary Business Value": "Provide a comprehensive view of all Wise work activities and understand their impact to the resource portfolio. Assure effective communications, coordination across workstreams in order to prevent delivery delays/failures.",
        "DE:WSP PRG Program Code #": "N/A",
        "DE:WSP PRG Program Sponsor": "{\"objCode\":\"USER\",\"name\":\"Scott Livingston\",\"ID\":\"5e4edbd300fa28183f47c65b9641d7cb\"}",
        "DE:WSP PRG Program Turned Red": "2021-02-01",
        "DE:WSP PRG Target For Green": "2021-03-03",
        "DE:WSP PRG Upcoming MS-1 Date": "2021-03-15",
        "DE:WSP PRG Upcoming MS-2 Date": "2021-02-26",
        "DE:WSP PRG Upcoming MS-3 Date": "2021-03-15",
        "DE:WSP PRG Upcoming MS-4 Date": "2021-03-22",
        "DE:WSP PRG Upcoming Milestone 1": "Fayetteville Go Live",
        "DE:WSP PRG Upcoming Milestone 2": "3475 - Path to GREEN Realized",
        "DE:WSP PRG Upcoming Milestone 3": "N/A",
        "DE:WSP PRG Upcoming Milestone 4": "N/A"
      },
      "portfolioID": "5bfc22ed00b20b189229e8201f3742b6",
      "securityRootID": "5e13939f00e62030bc40ae3a243f538c",
      "securityRootObjCode": "PRGM"
    },
    $$ val
)

select parse_json(parse_json(val):"parameterValues"."DE:WSP PRG GPM Partner"):name::varchar
from data
;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM