The correct answer is B. OBJECT_CONSTRUCT .
When unloading relational table data into semi-structured formats such as JSON, OBJECT_CONSTRUCT can be used to convert each relational row into an object. The resulting object can be represented as a single VARIANT value.
Why B is correct:
OBJECT_CONSTRUCT creates an object from key-value pairs. When used with *, it can construct an object from all columns in a row.
Example concept:
COPY INTO @my_stage/output/
FROM (
SELECT OBJECT_CONSTRUCT(*)
FROM my_table
)
FILE_FORMAT = (TYPE = JSON);
This transforms each relational row into a JSON-style object during unload.
Why the other options are incorrect:
A. ARRAY_AGG aggregates multiple values into an array, but it does not convert each relational row into an object.
C. TO_VARIANT converts a value to VARIANT, but it does not automatically construct a structured object from all row columns.
D. OBJECT_AGG is an aggregate function that creates an object from key-value pairs across rows, not the usual function for converting each relational row into a single object during unload.
Official Snowflake documentation reference:
Snowflake documentation explains that OBJECT_CONSTRUCT returns an object constructed from key- value pairs and can be used with COPY INTO < location > to unload relational rows as semi-structured data.
[Reference: Snowflake Documentation — OBJECT_CONSTRUCT; Snowflake Documentation — Unloading relational data to JSON; Snowflake Documentation — COPY INTO ; SnowPro Core Study Guide — Working with Semi-Structured Data., ========================]