nerdexam
Snowflake

DEA-C02 · Question #2

How can the following relational data be transformed into semi-structured data using the LEAST amount of operational overhead?

The correct answer is C. Use the OBJECT_CONSTRUCT function to return a Snowflake object.. OBJECT_CONSTRUCT is purpose-built for this exact transformation: it accepts key-value pairs from relational columns and assembles them into a single Snowflake OBJECT (a VARIANT) in one SQL expression, requiring no intermediate steps or data preparation. TO_JSON goes the wrong dir

Data Transformation

Question

How can the following relational data be transformed into semi-structured data using the LEAST amount of operational overhead?

Exhibit

DEA-C02 question #2 exhibit

Options

  • AUse the TO_JSON function.
  • BUse the PARSE_JSON function to produce a VARIANT value.
  • CUse the OBJECT_CONSTRUCT function to return a Snowflake object.
  • DUse the TO_VARIANT function to convert each of the relational columns to VARIANT.

How the community answered

(19 responses)
  • A
    16% (3)
  • B
    5% (1)
  • C
    74% (14)
  • D
    5% (1)

Explanation

OBJECT_CONSTRUCT is purpose-built for this exact transformation: it accepts key-value pairs from relational columns and assembles them into a single Snowflake OBJECT (a VARIANT) in one SQL expression, requiring no intermediate steps or data preparation. TO_JSON goes the wrong direction - it converts an existing VARIANT into a JSON string, not relational data into semi-structured data. PARSE_JSON requires a JSON-formatted string as input, meaning you'd first have to manually serialize your relational columns into a string before calling it - extra overhead. TO_VARIANT only converts individual scalar values column-by-column, so you'd need separate conversions per column and a way to combine them, making it the most operationally expensive option.

Memory tip: Think of the function names literally - OBJECT_CONSTRUCT constructs a new object from your data, which is exactly the "relational → semi-structured" direction. The others either expect semi-structured input (PARSE_JSON, TO_JSON) or work at the single-value level (TO_VARIANT).

Topics

#Data Transformation#Semi-structured Data#VARIANT Data Type#OBJECT_CONSTRUCT function

Community Discussion

No community discussion yet for this question.

Full DEA-C02 Practice