SOL-C01 · Question #299
You're building a Snowflake Notebook to automate data quality checks on a daily basis. You have a series of SQL queries, each representing a different quality rule (e.g., checking for null values…
The correct answer is A. Wrap each SQL query execution in a Python `try...except' block and log any exceptions to a C. Create a stored procedure in Snowflake that encapsulates each quality check and handles its own. For robust, fault-tolerant data quality checks where failures in one check should not stop subsequent checks: (A) Wrapping each SQL execution in a Python try...except block is the most direct approach within a notebook - it catches exceptions per check, logs them (e.g., to a…
Question
You're building a Snowflake Notebook to automate data quality checks on a daily basis. You have a series of SQL queries, each representing a different quality rule (e.g., checking for null values, duplicate records, invalid date formats). You want to implement error handling so that if one quality check fails, the notebook continues to execute the remaining checks and logs the errors. Which is the most robust approach to achieve this within the Snowflake Notebook environment, minimizing code complexity and maximizing fault tolerance?
Options
- AWrap each SQL query execution in a Python `try...except' block and log any exceptions to a
- BUse Snowflake's 'SYSTEM$LAST_CHANGE COMMIT _ TIME function to check if the SQL query
- CCreate a stored procedure in Snowflake that encapsulates each quality check and handles its own
- DWithin each SQL query, use Snowflake's ` TRY_CAST or similar error-handling functions to handle
- EEnable the 'AUTO_RETRY parameter at the account level, so failed queries are automatically
How the community answered
(56 responses)- A48% (27)
- B7% (4)
- D16% (9)
- E29% (16)
Explanation
For robust, fault-tolerant data quality checks where failures in one check should not stop subsequent checks: (A) Wrapping each SQL execution in a Python try...except block is the most direct approach within a notebook - it catches exceptions per check, logs them (e.g., to a Snowflake table or list), and allows the loop to continue; this minimizes complexity while maximizing control. (C) Encapsulating each quality check in a stored procedure with internal error handling (using Snowflake JavaScript or Python stored procedures with try/catch) separates concerns cleanly, making each check self-contained and reusable outside the notebook. Option B is incorrect - SYSTEM$LAST_CHANGE_COMMIT_TIME tracks DML commit times, not query success/failure. Option D (TRY_CAST) handles data type conversion errors within a query but cannot catch broader execution failures. Option E is incorrect - AUTO_RETRY is not a standard Snowflake account-level parameter for this use case.
Topics
Community Discussion
No community discussion yet for this question.