QUESTION 201
Consider the following scenario: You are ingesting JSON data from an external stage into Snowflake. The JSON data contains an array of objects, where each object represents a product with attributes like ‘product id’, ‘name’, and ‘price’. However, sometimes the ‘price’ field is missing entirely from some product objects. You want to load this data into a Snowflake table with columns ‘product_id’, ‘name’, and ‘price’ (defined as NUMBER). How can you handle the missing ‘price’ field gracefully during the COPY INTO operation, ensuring that missing prices are represented as NULL in the Snowflake table without causing errors?
Option B is the most effective approach using Snowflake’s built-in features. TRY TO NUMBER will return NULL if ‘price’ is missing, ensuring that NULL is inserted into the NUMBER column, avoiding errors. Option A does not work, DEFAULT NULL is not respected on column mappings. C does not work since VARCHAR and NULLIFEMPTY do not meet all the requirments. Option D works, but is not the most efficient. Option E requires unnecessary pre-processing.