
Answer-first summary for fast verification
Answer: OBJECT_CONSTRUCT
The question asks for the recommended Snowflake function when unloading data from a relational table into a JSON file. OBJECT_CONSTRUCT is the optimal choice because it explicitly constructs JSON objects from relational data, making it ideal for transforming structured table data into JSON format during unload operations. TO_JSON converts existing VARIANT data to JSON strings but doesn't construct JSON objects from relational columns, making it less suitable for this specific use case. TO_VARIANT converts data to VARIANT type but not specifically to JSON format. OBJECT_INSERT modifies existing objects rather than creating new ones from relational data. The community discussion shows divided opinions between TO_JSON (67%) and OBJECT_CONSTRUCT (33%), but OBJECT_CONSTRUCT is more appropriate for constructing JSON from relational table structures.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.