Skip to content

Commit

Permalink
use fully qualified column name in unions
Browse files Browse the repository at this point in the history
better support for an edge case in Bigquery, which gets confused by casting a column with the same name as its parent table. Fixes dbt-labs#173
  • Loading branch information
wearpants authored Nov 7, 2019
1 parent 49e6894 commit 70d5284
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions macros/sql/union.sql
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@

{%- set col = column_superset[col_name] %}
{%- set col_type = column_override.get(col.column, col.data_type) %}
{%- set col_name = adapter.quote(col_name) if col_name in table_columns[table] else 'null' %}
cast({{ col_name }} as {{ col_type }}) as {{ col.quoted }} {% if not loop.last %},{% endif %}
{%- set col_name = adapter.quote(table.name) + '.' + adapter.quote(col_name) if col_name in table_columns[table] else 'null' %} cast({{ col_name }} as {{ col_type }}) as {{ col.quoted }} {% if not loop.last %},{% endif %}
{%- endfor %}

from {{ table }}
Expand Down

0 comments on commit 70d5284

Please sign in to comment.