Which function is used to unload a relational table into a JSON file?
Which function is used to unload a relational table into a JSON file?
D. TO_JSON Explanation: TO_JSON is used to convert relational data into JSON format, which is ideal when unloading a relational table into a JSON file. Why the others are wrong: A. PARSE_JSON: This function is used to parse a JSON string into a Snowflake-compatible format, not for converting relational data into JSON. B. JSON_EXTRACT_PATH_TEXT: This function extracts specific values from JSON data, but it doesn't convert relational data into JSON. C. OBJECT_CONSTRUCT: This creates a JSON object from key-value pairs, but it doesn't convert the entire relational data into JSON format. Example of using TO_JSON: SELECT TO_JSON(OBJECT_CONSTRUCT(*)) FROM my_table;
D is correct, I think the first two are for unloading json and C needs the COPY INTO [location] to successfully unload json
I'm changing my answer to C
Answer is D. OBJECT_CONSTRUCT Returns an OBJECT constructed from the arguments -- NOT JSON
The TO_JSON function in Snowflake is used to convert relational data into a JSON-formatted string. It is the appropriate function to use when unloading a relational table into a JSON file, as it serializes the data into a JSON representation.