06 October 2018 · n-pacha ·       Add to Favorites   Report

BigQuery - Handling Division by Zero Error

Consider you have to do x/y returning null, if y=0, however, In BigQuery it will throw the error:

Error: division by zero

Solution:

In standard SQL you can use,

SAFE_DIVIDE(x, y)
It is equivalent to the division operator (/). Returns NULL if an error occurs, such as division by zero


Read great educational content like this and a lot more !

Members get free exclusive access to content, new courses, and discounts. Signup for a free account to write a post / comment / upvote posts. Creating an account takes less than 5 seconds and you can start earning badges & points too

Copied