title: BigQuery equivalent of COALESCE()?
body: <p>I'm in the process of converting some aggregate queries from Postgres to our new architecture in BigQuery.  Is there an equivalent of COALESCE() in BigQuery?</p>
  
  <p>Currently, I am converting a Postgres query statement like </p>
  
  <pre><code>coalesce(column1,'DEFAULT')
  </code></pre>
  
  <p>to</p>
  
  <pre><code>CASE
    WHEN column1 IS NOT NULL
       THEN column1
     ELSE 'DEFAULT'
  END AS column1
  </code></pre>
  
  <p>which seems easy enough.</p>
  
  <p>However converting a Postgres query statement with nested coalesce statements like</p>
  
  <pre><code> count(distinct coalesce(
                  coalesce(
                  coalesce(column1,column2),
                                   column3),
                                   column4)))
  </code></pre>
  
  <p>would get much more messy if I used <code>CASE</code> statements all over the place, and also seems like the wrong thing to do.</p>
  
  <p>Does BigQuery have a method equivilent to <code>COALESCE()</code>, or am I stuck writing the whole <code>CASE</code> statement equivalent?</p>