Code sql

Snowflake - Flatten nested JSON array

Kontext Kontext visibility 95 comment 0 access_time 4 months ago language English

descriptionCode description

Snowflake provides a number of JSON related functions to convert string (varchar) to JSON object and extract JSON values from the object or flatten nested array, etc. 

The code snippet shows an example of flattening the following JSON string using lateral flatten:

{
   "a":"a",
   "b":[
      {
         "c":"c1",
         "d":[
            1,
            2,
            3,
            4,
            5,
            6,
            7
         ]
      },
      {
         "c":"c2",
         "d":[
            10,
            20,
            30,
            40,
            50,
            60,
            70
         ]
      }
   ]
}
fork_rightFork
more_vert
copyright This page is subject to Site terms.
comment Comments
No comments yet.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts