The correct answer is A. Use the OBJECT_CONSTRUCT function with the COPY INTO < location > command .
When unloading relational data to JSON, each relational row must be transformed into a single semi-structured object. OBJECT_CONSTRUCT creates a JSON-style object from the row’s columns, and COPY INTO < location > unloads the result to a stage.
Why A is correct:
Snowflake requires unloaded JSON data to be represented as a single VARIANT, OBJECT, or ARRAY value per row. OBJECT_CONSTRUCT converts relational columns into an object suitable for JSON unload.
Example:
COPY INTO @my_stage/output/
FROM (
SELECT OBJECT_CONSTRUCT(*)
FROM customers
)
FILE_FORMAT = (TYPE = JSON);
Why the other options are incorrect:
B. Setting the file format to JSON alone is not sufficient for relational rows with multiple columns. The rows must be converted into a single semi-structured column.
C. PUT uploads local files to an internal stage. It does not unload table data.
D. GET downloads files from an internal stage to a local machine. It does not unload table data from Snowflake.
Official Snowflake documentation reference:
Snowflake documentation explains that to unload relational data to JSON, the query should return a single column containing semi-structured data, commonly produced with OBJECT_CONSTRUCT.
[Reference: Snowflake Documentation — Unloading relational data to JSON; Snowflake Documentation — OBJECT_CONSTRUCT; Snowflake Documentation — COPY INTO ; SnowPro Core Study Guide — Data Loading and Unloading., , , ]
Submit