nerdexam
Snowflake

SOL-C01 · Question #97

You are loading JSON data into Snowflake. The JSON data contains nested arrays and objects. You need to flatten specific arrays while retaining other nested structures for analysis. Which combination

The correct answer is E. Utilize `LATERAL FLATTEN' function with the 'PATH' parameter to target specific arrays for. LATERAL FLATTEN with the PATH parameter is the correct approach because it lets you target a specific nested array by name while leaving other nested structures untouched - exactly what the question requires. Option A is wrong because RECURSIVE = TRUE flattens all nested structur

Data Loading and Unloading

Question

You are loading JSON data into Snowflake. The JSON data contains nested arrays and objects. You need to flatten specific arrays while retaining other nested structures for analysis. Which combination of Snowflake functions and clauses would best achieve this?

Options

  • AUse FLATTEN' function with 'RECURSIVE = TRUE to flatten all nested structures indiscriminately.
  • BUse LATERAL FLATTEN' function with PATH' parameter to specify the array to be flattened, and
  • CUse `GET PATH' to extract specific elements from the JSON and load them directly into separate
  • DUse only FLATTEN' function without specifying 'PATH' and then use 'RECURSIVE = FALSE
  • EUtilize `LATERAL FLATTEN' function with the 'PATH' parameter to target specific arrays for

How the community answered

(52 responses)
  • A
    15% (8)
  • B
    6% (3)
  • C
    2% (1)
  • D
    8% (4)
  • E
    69% (36)

Explanation

LATERAL FLATTEN with the PATH parameter is the correct approach because it lets you target a specific nested array by name while leaving other nested structures untouched - exactly what the question requires. Option A is wrong because RECURSIVE = TRUE flattens all nested structures indiscriminately, destroying nested objects you want to preserve. Option B appears to be a truncated version of E describing the same correct approach but is incomplete as presented. Option C is wrong because GET_PATH only extracts scalar values from JSON - it doesn't flatten arrays into rows. Option D is wrong because omitting PATH causes FLATTEN to operate on the entire variant column without targeting a specific array, giving you no control over which arrays are expanded.

Memory tip: Think of PATH as a "sniper scope" - LATERAL FLATTEN is the gun, but without PATH you're firing blindly at everything. The word lateral also signals row-level expansion (one row per array element), which is what flattening means in SQL.

Topics

#JSON flattening#LATERAL FLATTEN#PATH parameter#nested structures

Community Discussion

No community discussion yet for this question.

Full SOL-C01 Practice