Equivalent to BigQuery COALESCE ()?

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?

+4
source share
1 answer

IFNULL BigQuery, :

select ifnull(column1,
              ifnull(column2,'DEFAULT')) 
from 
(select string(NULL) as column1, 'y' as column2)

P.S. COALESCE BigQuery - , .

: 4/16/2015 COALESCE BigQuery.

+10

All Articles