BigQuery - IFERROR for standardSQL
Asked Answered
W

1

15

I'm about to migrate queries from Legacy to Standard in BQ. In Legacy I used to have x/y returning null if y=0, however, I'm stuck in StandardSQL with the error:

Error: division by zero

I'd like to apply something like IFERROR(x/y,null)

Is it available in StandardSQL?

Winker answered 18/3, 2018 at 9:14 Comment(0)
P
28

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

Palaeobotany answered 18/3, 2018 at 9:20 Comment(1)
Official docs here: cloud.google.com/bigquery/docs/reference/standard-sql/…Bloomy

© 2022 - 2024 — McMap. All rights reserved.