I am going to convert some aggregate queries from Postgres to our new architecture in BigQuery. Is there an equivalent to COALESCE () in BigQuery?
I am currently converting a Postgres request request, for example
coalesce(column1,'DEFAULT')
to
CASE
WHEN column1 IS NOT NULL
THEN column1
ELSE 'DEFAULT'
END AS column1
which seems simple enough.
However, transforming a Postgres query statement with nested coalesce statements such as
count(distinct coalesce(
coalesce(
coalesce(column1,column2),
column3),
column4)))
would be much more messy if I used operators CASEeverywhere, and also doesn't seem to be that way.
Does BigQuery have an equivalent method, COALESCE()or am I stuck in writing the whole expression CASE?
source
share