BigQuery raises exception if query with joins are not flattened
<p>Query is:</p>

<pre><code>select
    cb.subnum as subnum,
    last(
        if(
            (if(cu.smartcard_number is not null, 1, 0)) +
            (if(rr.smart_card_number is not null, 1, 0)) &gt; 0, 1, 0)   
    ) as econnected_i,

from 
    combined.table1 as cb

left outer join each dataflow_raw_eu.table2 as cu
on cu.smartcard_number = cb.smart_card_num

left outer join each dataflow_raw_eu.table3 as rr
on rr.smart_card_number = cb.smart_card_num

group by subnum
</code></pre>

<p>The error is:</p>

<blockquote>
  <p>Error: Ambiguous field name 'imported_at' in JOIN. Please use the table qualifier before field name. </p>
</blockquote>

<p>I noticed that when it runs with only one join, of either table, then the query succeeds. <code>imported_at</code> is a timestamp field shared by all 3 tables (the only field shared by all 3), but it is not included in the query.</p>

<p>If I select <code>flatten_results</code> in the BigQuery options, then the query succeeds; but I wish to run future queries with nested records. None of the tables in the above query have a repeated or record field.</p>