BigQuery: Coalesce converts TIMESTAMP to INTEGER
<p>I'm experiencing a problem with COALESCE function, when applied to TIMESTAMP field it converts it to INTEGER 
Here is the example</p>

<pre><code>SELECT 
   c_date AS c_date,
   COALESCE(nd.c_datetime, od.c_datetime) AS c_datetime,
   COALESCE(nd.c_timestamp, od.c_timestamp) AS c_timestamp 
FROM [table1] as nd 
LEFT JOIN [table2] as od ON  nd.c_date = od.c_date ";
</code></pre>

<p>Though all 3 fields in both tables have TIMESTAMP type, query will return first one as TIMESTAMP, but  all the others will become INTEGER. Is this intended behaviour? </p>

<p>P.S. I found a workaround </p>

<pre><code> USEC_TO_TIMESTAMP(COALESCE(nd.c_datetime, od.c_datetime)) AS c_datetime
</code></pre>

<p>but it's pretty strange that simple coalesce requires special actions to preserve type</p>

<p>P.P.S. I know that guys from Google are reading stackoverflow. The job id is job_vM_1Kxo4NBp5Ae3VmLmAI-4OXpo  . Hope it will help you!</p>