Handle BigQuery error from the querying by using Python

529 views Asked by At

To handle the errors from bigquery I have used - job.errors[0]['message'] and everything was fine so far.

The issue is when you querying and for example, when you divide the value by 0, BigQuery will show you:

enter image description here

QUESTION: By using PYTHON - HOW to pick up this error?

1

There are 1 answers

2
Mikhail Berlyant On

Or, in BigQuery Standard SQL, you can use SAFE_DIVIDE() to avoid error

SAFE_DIVIDE() is equivalent to the division operator (/), but returns NULL if an error occurs, such as a division by zero error

So instead of SELECT 15 / 0 you should use SAFE_DIVIDE(15, 0)