From 70d52849962e13050e56fa64aefe3e5e2758901c Mon Sep 17 00:00:00 2001 From: Peter Fein Date: Wed, 6 Nov 2019 21:27:28 -0500 Subject: [PATCH] use fully qualified column name in unions better support for an edge case in Bigquery, which gets confused by casting a column with the same name as its parent table. Fixes #173 --- macros/sql/union.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/macros/sql/union.sql b/macros/sql/union.sql index 5fcde0cd..5fae8152 100644 --- a/macros/sql/union.sql +++ b/macros/sql/union.sql @@ -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 }}