In many RDBMS Databases there is a mechanism to handle the exception in stored procedures and functions. Is there any way in bigquery to handle the run time exceptions? Like no data found or subscript beyond count?
BigQuery hasn't documented it yet, but you can handle any type of exception in BigQuery by creating an exception handling clause, as described in the following example:
BEGIN
SELECT 1/0;
EXCEPTION WHEN ERROR THEN
SELECT @@error.message, @@error.statement_text;
END;
In the above example, the EXCEPTION block is entered whenever an exception occurs in the BEGIN block above it. Inside the exception block, @@error.message evaluates to a string describing the error, and @@error.statement_text is the text of the statement which caused the error.
Be aware that, as this feature has not been formally documented yet, the syntax is still subject to change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With