flatten JSON value stored as varchar in snowflake to columns

Viewed 24

one of our tables in snowflake contains the below kind of json value stored as a varchar

  • enter image description here

How do I get to this?

  • enter image description here

in this example I have achieved this by using SPLIT_PART

Not all values have two keys inside the json:

  • enter image description here

in the above case I want it to look like this:

  • enter image description here

And effectively, how to I ensure that I capture the case that more keys and values come into the json?.. 2 more columns?... how can I write a query that can automatically count for all the cases??, or is that not recommended?

0 Answers
Related