The correct answer is C. PARSE_JSON .
PARSE_JSON parses a valid JSON-formatted string and returns a VARIANT value. This is commonly used when inserting semi-structured JSON data into a VARIANT column.
Why C is correct:
A VARIANT column can store semi-structured data such as JSON objects and arrays. When the source value is a JSON string, PARSE_JSON converts it into a Snowflake VARIANT.
Example:
CREATE TABLE json_table (
src VARIANT
);
INSERT INTO json_table
SELECT PARSE_JSON( ' { " customer_id " : 101, " region " : " WEST " } ' );
Why the other options are incorrect:
A. TO_JSON converts a VARIANT value into a JSON string. It is commonly used in the opposite direction.
B. TO_VARCHAR converts a value to a string, not to a semi-structured VARIANT.
D. OBJECT_INSERT inserts or updates a key-value pair inside an existing object, but it is not the primary function used to parse JSON text into a VARIANT column.
Official Snowflake documentation reference:
Snowflake documentation describes PARSE_JSON as a function that interprets an input string as JSON and returns a VARIANT value.
[Reference: Snowflake Documentation — PARSE_JSON; Snowflake Documentation — Semi-structured data types; SnowPro Core Study Guide — Working with Semi-Structured Data., ========================]
Submit