Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how we can handle exceptions in procedures in bigquery?

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?

like image 700
Krishnareddy Shada Avatar asked Oct 27 '25 05:10

Krishnareddy Shada


1 Answers

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.

like image 96
Eric Feiveson Avatar answered Oct 29 '25 18:10

Eric Feiveson