QuestionQ44

Transform Data

The following semi-structured JSON data is stored in a VARIANT column named raw_json in the tbl_emp_raw table.

Question Image

Which query produces the following output?

Question Image

Explanation

FLATTEN applied laterally to the spoken_languages array returns one row for each array element. Each element is an object containing language and level, and that individual object is exposed through the FLATTEN output column VALUE. Accessing f1.value:language and f1.value:level therefore returns the two required rows and columns. Snowflake documents VALUE as the value of the flattened array or object element.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!