Exam SnowPro Core All QuestionsBrowse all questions from this exam
Question 823

A JSON document is stored in the source_column of type VARIANT. The document has an array called elements. The array contains the name key that has a string value.

How can a Snowflake user extract the name from the first element?

    Correct Answer: D

Discussion
HeetecOption: D

D correct

SSaharOption: C

I think the answer should be C: Based on the output of the FLATTEN function, +-----+------+------+-------+-------+------+ | SEQ | KEY | PATH | INDEX | VALUE | THIS | |-----+------+------+-------+-------+------| Key is the second output, therefore source_column:elements[1].name should point to the key. Not sure though :\

SSahar

D is correct

ahadh7621

This is not related to the FLATTEN function. This is merely a question on traversing semi-structured datatypes: https://docs.snowflake.com/en/user-guide/querying-semistructured Insert a colon : between the VARIANT column name and any first-level element: <column>:<level1_element>. There are two ways to access elements in a JSON object: Dot Notation Bracket Notation Retrieve a specific numbered instance of a child element in a repeating array by adding a numbered predicate (starting from 0) to the array reference. so the answer is D