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 }}