如何将JSON数据转换为结构化数据

发布于 2025-02-04 20:52:19 字数 8869 浏览 2 评论 0原文

有2列摄入到雪花后,我想使下面的第二列插入结构和关系数据。

现在低于点1和点2,是两个不同的列数据,我希望从下面的JSON数据中得出结构数据。任何人都可以在雪花中提供所需的功能/过程,

  1.  **First Column Data**: {
      "Create-time": 1654252931867,
      "offset": 0,
      "partition": 0,
      "topic": "get-text_MSG"
    }
    
    
   2. **Second Column Data**:
    {
      "parser-output": [
        {
          "OB": "NV",
          "MG": "product",
          "product_id": "B7CY2YG"
        },
        {
          "OB": "NV",
          "MG": "product",
          "author_name": "Chef Store"
        },
        {
          "OB": "NV",
          "MG": "product",
          "images_chunk": "https://m.media-myntra.com/I/31d_AC_US500_.jpg",
          "images_chunk_popup": "https://m.media-myntra.com/I/719U_AC_SL1500_.jpg",
          "images_chunk_popup_large": "https://m.media-myntra.com/I/31d4-P1gSkL._AC_.jpg",
          "manufacturer_text": "so you comm rest assure that your stove will be protected from all the outdoor elements. |#Fitment DB-60D",
          "no_of_images": 1,
          "no_of_images_popup": "1",
          "no_of_images_popup_large": "1",
          "no_of_user_manual": "n/a",
          "no_of_videos": "0",
          "product_image": "https://m.media-myntra.com/images/I/719Un2I2VjL._AC_SL1500_.jpg",
          "user_manual_chunk": "n/a",
          "videos_links": ""
        },
        {
          "OB": "NV",
          "MG": "product",
          "installation_features": "n/a",
          "installation_price": "n/a",
          "lead_time": "n/a",
          "seller_name": "",
          "shipping_message": "FREE delivery: n/a"
        },
        {
          "OB": "NV",
          "MG": "product",
          "delivery_lead-time": "n/a",
          "frequently_asked_question": "Customer Questions & Answers",
          "image_alt_text": "comp Chef PC46 Cover for DB60D & SGP60B Cookers",
          "item_condition_price": "n/a",
          "long_description": "Its secured to the stove by a set of bungee cords and hooks. This durable cover comes in a khaki tan color which will look great on the patio or at the base comm. Features -Weather-resistant liner. -Bungee cords and hooks for wind protection. -Durable construction for patio or base comm. Specification 46\"x16\"x14\". Weight: 2 lbs.#||#",
          "long_features": "DB-60D",
          "manufacturer_content": "Yes",
          "mp": "PC46",
          "no_of_customer_reviews_greater_21": "No",
          "preferred_product_barge": "No",
          "schema_org_availability": "No",
          "star_1": 1.05,
          "star_2": 1.65,
          "star_3": 1.05,
          "star_4": 2.55,
          "star_5": 8.85,
          "three_sixty_spin": "",
          "total_customer_ratings": "15"
        },
        {
          "OB": "NV",
          "MG": "product",
          "average_rating": "4.1",
          "best_seller_ranking": "160115",
          "brand": "comp Chef",
          "buy-box_winner_name": "n/a",
          "category_path": "Patio, Lawn & Garden#||#Barbecue Grills & Outdoor Cooking#||#Barbecue & Smoker Accessories#||#Barbecue Covers",
          "features": "comp Chef cover #||# Protects your stove from the elements; the covers are secured to the stove by a set of bungee cords and hooks #||# Made with weather resistant material #||# Fits models DB-60, SPG-60P, PRC-60P #||# Measures 46-inches in length by 16-inches in height by 14-inches in width",
          "image_URL_large": "https://m.media-mantra.com/I/719UAC_SL1500_.jpg",
          "image_URL_small": "https://m.media-mantra.com/I/719UAC_SL1500_.jpg",
          "page_title": "comm Chef PC46 Cover for DB60D & SGP60B Cookers : mantra.com: Patio, Lawn & Garden",
          "product_description": "The comp Chef PC46. Protect your outdoor cooker. Durable construction. Fits models DB-60 and SPG-60",
          "product_image": "https://m.media-myntra.com/images/I/719Un2I2VjL._AC_SL1500_.jpg",
          "product_name": "comp Chef PC46 Cover for DB60D & SGP60B Cookers",
          "stock_status": "Currently unavailable",
          "user_manual": "N"
        },
        {
          "OB": "NV",
          "MG": "product",
          "stock_message": "Currently unavailable.",
          "stock_status_flag": "0"
        },
        {
          "OB": "NV",
          "MG": "product",
          "URL": "https://www.myntra.com/commp-Chef-PC46-SGP60B-Cookers/dp/B0007CY2YG"
        },
        {
          "OV": "NV",
          "MG": "meta",
          "char-set": "utf-8"
        },
        {
          "OB": "NV",
          "MG": "meta",
          "x-dens-pref etch-control": "on"
        },
        {
          "OB": "NV",
          "MG": "meta",
          "content-type": "text/HTML; char-set=iso-8859-1"
        },
        {
          "OB": "NV",
          "MG": "meta",
          "robots": "NO-INDEX"
        },
        {
          "OB": "NV",
          "MG": "meta",
          "description": "comp Chef PC46 Cover for DB60D & SGP60B Cookers : myntra.com: Patio, Lawn & Garden"
        },
        {
          "OB": "NV",
          "MG": "meta",
          "title": "comp Chef PC46 Cover for DB60D & SGP60B Cookers : mantra.com: Patio, Lawn & Garden"
        },
        {
          "OB": "NV",
          "MG": "meta",
          "title": "comp Chef PC46 Cover for DB60D & SGP60B Cookers : mantra.com: Patio, Lawn & Garden"
        },
        {
          "OB": "NV",
          "MG": "meta",
          "communication": "https://www.mantra.com/commp-Chef-PC46-SGP60B-Cookers/dp/B0007CY2YG"
        },
        {
          "OB": "NV",
          "MG": "TD"
        },
        {
          "OB": "NV",
          "MG": "product",
          "time_to_parse": "1322 ms"
        }
      ],
      "URL-metadata": {
        "batch": "2022",
        "category": "[{\"MG\": \"product\", \"product_id\": \"B0007CY2YG\", \"OB\": \"NV\"}]",
        "child-flag": false,
        "Mg-relation": false,
        "domain": "mantra_com",
        "encoding": "UTF-8",
        "environment": "Prod-THE",
        "fetching-texture": true,
        "gateway-type": "CLIENTELE",
        "info": {
          "current-time": 1650698639108,
          "duration": 354,
          "envy": "Prod-THUD",
          "page-type": [
            "product_page",
            "variation_page"
          ],
          "proxy": "gamut_proxy",
          "URL": "https://www.myntra.com/dp/B0007CY2YG/?m=A3DWYIK6Y9EEQB"
        },
        "job-id": 1649735439979,
        "job-size": 0,
        "last-get-text-time": 1650698635,
        "page-depth": [
          "product_page",
          "variation_page"
        ],
        "parenthetical-catalogued": "https://www.myntra.com/dp/B0007CY2YG/?m=A3DWYIK6Y9EEQB",
        "product-info": false,
        "project": "The Home Depot command - Competitive Intelligence",
        "project Id": "P39260633533984451",
        "machine": "XX.XX.XX.XXX:8800",
        "region": "Canada",
        "request-metadata": {
          "allow-redirect": true,
          "cookies": {
            "i18n-prefs": "com",
            "session-id": "146-0873333-2440418",
            "session-id-time": "2082787201l"
          },
          "header-parameters": {
            "Accept": "text/HTML,complication/HTML+XML,application/XML;q=0.9,image/avid,image/web,image/pang,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
            "Accept-Encoding": "grip, deflate, Br",
            "Accept-Language": "en-GB,en-US;q=0.9,en;q=0.8",
            "Connection": "keep-alive",
            "Host": "WWW.mantra.com",
            "User-Agent": "Mozilla/5.0 (X11; CrOSarmv7l 8172.62.0) Hepplewhite/537.36 (HTML,like Gecko) Chrome/51.0.2704.106 Safari/537.36"
          },
          "verify": false,
          "web-method": "get"
        },
        "retailer": "mantra_com",
        "retry-count": 1,
        "row-key": "5b9b34b4e652e3f65dcomc1412e68ed17-1649735439979",
        "scripts": [
          "mantra_com_product_page"
        ],
        "persiflage": true,
        "start-time": 1650718263000,
        "sub-batch": "April",
        "sub-project": "Competitive Intelligence",
        "total-input": "[{\"\",\"Sid_SUB_CLASS_NOR\":\"n/a\",\"Sid_rival_presence_order\":\"n/a\",\"id\":\"n/a\"}]",
        "type": "product_page",
        "unique-identifier": "35644",
        "unique-Eyebrow": "1649735439979_1642922463000",
        "unique-Interscholastic": 1650698635,
        "URL": "https://www.myntra.com/dp/B0007CY2YG/?m=A3DWYIK6Y9EEQB",
        "validate-Parsed-output": false,
        "validation_check": {},
        "vendor": "default",
        "volatility": 0
      }
    }

请不要为上述问题提供Java或Python代码。在雪花中很有可能。因为由于数据流管线的任何结构性变化,因此很难以其他语言管理其他语言的编码,因为它很容易

SAMPLE OUTPUTThere are 2 columns post ingestion to snowflake, I want to make the 2nd column inserted below to structural and relational data.

Now below the point 1 and point 2 are two different columns data, that I want into structural data to be derived from this JSON data below. Can anyone help with required function/procedure in Snowflake

  1.  **First Column Data**: {
      "Create-time": 1654252931867,
      "offset": 0,
      "partition": 0,
      "topic": "get-text_MSG"
    }
    
    
   2. **Second Column Data**:
    {
      "parser-output": [
        {
          "OB": "NV",
          "MG": "product",
          "product_id": "B7CY2YG"
        },
        {
          "OB": "NV",
          "MG": "product",
          "author_name": "Chef Store"
        },
        {
          "OB": "NV",
          "MG": "product",
          "images_chunk": "https://m.media-myntra.com/I/31d_AC_US500_.jpg",
          "images_chunk_popup": "https://m.media-myntra.com/I/719U_AC_SL1500_.jpg",
          "images_chunk_popup_large": "https://m.media-myntra.com/I/31d4-P1gSkL._AC_.jpg",
          "manufacturer_text": "so you comm rest assure that your stove will be protected from all the outdoor elements. |#Fitment DB-60D",
          "no_of_images": 1,
          "no_of_images_popup": "1",
          "no_of_images_popup_large": "1",
          "no_of_user_manual": "n/a",
          "no_of_videos": "0",
          "product_image": "https://m.media-myntra.com/images/I/719Un2I2VjL._AC_SL1500_.jpg",
          "user_manual_chunk": "n/a",
          "videos_links": ""
        },
        {
          "OB": "NV",
          "MG": "product",
          "installation_features": "n/a",
          "installation_price": "n/a",
          "lead_time": "n/a",
          "seller_name": "",
          "shipping_message": "FREE delivery: n/a"
        },
        {
          "OB": "NV",
          "MG": "product",
          "delivery_lead-time": "n/a",
          "frequently_asked_question": "Customer Questions & Answers",
          "image_alt_text": "comp Chef PC46 Cover for DB60D & SGP60B Cookers",
          "item_condition_price": "n/a",
          "long_description": "Its secured to the stove by a set of bungee cords and hooks. This durable cover comes in a khaki tan color which will look great on the patio or at the base comm. Features -Weather-resistant liner. -Bungee cords and hooks for wind protection. -Durable construction for patio or base comm. Specification 46\"x16\"x14\". Weight: 2 lbs.#||#",
          "long_features": "DB-60D",
          "manufacturer_content": "Yes",
          "mp": "PC46",
          "no_of_customer_reviews_greater_21": "No",
          "preferred_product_barge": "No",
          "schema_org_availability": "No",
          "star_1": 1.05,
          "star_2": 1.65,
          "star_3": 1.05,
          "star_4": 2.55,
          "star_5": 8.85,
          "three_sixty_spin": "",
          "total_customer_ratings": "15"
        },
        {
          "OB": "NV",
          "MG": "product",
          "average_rating": "4.1",
          "best_seller_ranking": "160115",
          "brand": "comp Chef",
          "buy-box_winner_name": "n/a",
          "category_path": "Patio, Lawn & Garden#||#Barbecue Grills & Outdoor Cooking#||#Barbecue & Smoker Accessories#||#Barbecue Covers",
          "features": "comp Chef cover #||# Protects your stove from the elements; the covers are secured to the stove by a set of bungee cords and hooks #||# Made with weather resistant material #||# Fits models DB-60, SPG-60P, PRC-60P #||# Measures 46-inches in length by 16-inches in height by 14-inches in width",
          "image_URL_large": "https://m.media-mantra.com/I/719UAC_SL1500_.jpg",
          "image_URL_small": "https://m.media-mantra.com/I/719UAC_SL1500_.jpg",
          "page_title": "comm Chef PC46 Cover for DB60D & SGP60B Cookers : mantra.com: Patio, Lawn & Garden",
          "product_description": "The comp Chef PC46. Protect your outdoor cooker. Durable construction. Fits models DB-60 and SPG-60",
          "product_image": "https://m.media-myntra.com/images/I/719Un2I2VjL._AC_SL1500_.jpg",
          "product_name": "comp Chef PC46 Cover for DB60D & SGP60B Cookers",
          "stock_status": "Currently unavailable",
          "user_manual": "N"
        },
        {
          "OB": "NV",
          "MG": "product",
          "stock_message": "Currently unavailable.",
          "stock_status_flag": "0"
        },
        {
          "OB": "NV",
          "MG": "product",
          "URL": "https://www.myntra.com/commp-Chef-PC46-SGP60B-Cookers/dp/B0007CY2YG"
        },
        {
          "OV": "NV",
          "MG": "meta",
          "char-set": "utf-8"
        },
        {
          "OB": "NV",
          "MG": "meta",
          "x-dens-pref etch-control": "on"
        },
        {
          "OB": "NV",
          "MG": "meta",
          "content-type": "text/HTML; char-set=iso-8859-1"
        },
        {
          "OB": "NV",
          "MG": "meta",
          "robots": "NO-INDEX"
        },
        {
          "OB": "NV",
          "MG": "meta",
          "description": "comp Chef PC46 Cover for DB60D & SGP60B Cookers : myntra.com: Patio, Lawn & Garden"
        },
        {
          "OB": "NV",
          "MG": "meta",
          "title": "comp Chef PC46 Cover for DB60D & SGP60B Cookers : mantra.com: Patio, Lawn & Garden"
        },
        {
          "OB": "NV",
          "MG": "meta",
          "title": "comp Chef PC46 Cover for DB60D & SGP60B Cookers : mantra.com: Patio, Lawn & Garden"
        },
        {
          "OB": "NV",
          "MG": "meta",
          "communication": "https://www.mantra.com/commp-Chef-PC46-SGP60B-Cookers/dp/B0007CY2YG"
        },
        {
          "OB": "NV",
          "MG": "TD"
        },
        {
          "OB": "NV",
          "MG": "product",
          "time_to_parse": "1322 ms"
        }
      ],
      "URL-metadata": {
        "batch": "2022",
        "category": "[{\"MG\": \"product\", \"product_id\": \"B0007CY2YG\", \"OB\": \"NV\"}]",
        "child-flag": false,
        "Mg-relation": false,
        "domain": "mantra_com",
        "encoding": "UTF-8",
        "environment": "Prod-THE",
        "fetching-texture": true,
        "gateway-type": "CLIENTELE",
        "info": {
          "current-time": 1650698639108,
          "duration": 354,
          "envy": "Prod-THUD",
          "page-type": [
            "product_page",
            "variation_page"
          ],
          "proxy": "gamut_proxy",
          "URL": "https://www.myntra.com/dp/B0007CY2YG/?m=A3DWYIK6Y9EEQB"
        },
        "job-id": 1649735439979,
        "job-size": 0,
        "last-get-text-time": 1650698635,
        "page-depth": [
          "product_page",
          "variation_page"
        ],
        "parenthetical-catalogued": "https://www.myntra.com/dp/B0007CY2YG/?m=A3DWYIK6Y9EEQB",
        "product-info": false,
        "project": "The Home Depot command - Competitive Intelligence",
        "project Id": "P39260633533984451",
        "machine": "XX.XX.XX.XXX:8800",
        "region": "Canada",
        "request-metadata": {
          "allow-redirect": true,
          "cookies": {
            "i18n-prefs": "com",
            "session-id": "146-0873333-2440418",
            "session-id-time": "2082787201l"
          },
          "header-parameters": {
            "Accept": "text/HTML,complication/HTML+XML,application/XML;q=0.9,image/avid,image/web,image/pang,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
            "Accept-Encoding": "grip, deflate, Br",
            "Accept-Language": "en-GB,en-US;q=0.9,en;q=0.8",
            "Connection": "keep-alive",
            "Host": "WWW.mantra.com",
            "User-Agent": "Mozilla/5.0 (X11; CrOSarmv7l 8172.62.0) Hepplewhite/537.36 (HTML,like Gecko) Chrome/51.0.2704.106 Safari/537.36"
          },
          "verify": false,
          "web-method": "get"
        },
        "retailer": "mantra_com",
        "retry-count": 1,
        "row-key": "5b9b34b4e652e3f65dcomc1412e68ed17-1649735439979",
        "scripts": [
          "mantra_com_product_page"
        ],
        "persiflage": true,
        "start-time": 1650718263000,
        "sub-batch": "April",
        "sub-project": "Competitive Intelligence",
        "total-input": "[{\"\",\"Sid_SUB_CLASS_NOR\":\"n/a\",\"Sid_rival_presence_order\":\"n/a\",\"id\":\"n/a\"}]",
        "type": "product_page",
        "unique-identifier": "35644",
        "unique-Eyebrow": "1649735439979_1642922463000",
        "unique-Interscholastic": 1650698635,
        "URL": "https://www.myntra.com/dp/B0007CY2YG/?m=A3DWYIK6Y9EEQB",
        "validate-Parsed-output": false,
        "validation_check": {},
        "vendor": "default",
        "volatility": 0
      }
    }

Please don't give the JAVA or PYTHON code for the above problem. As its much possible in SNOWFLAKE. Because as its very hard to manage the coding in other language other than in the SNOWFLAKE SQL as it would be very easy later in case of any structural changes in the data flow pipeline

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文