diff --git a/CHANGELOG.md b/CHANGELOG.md index d524b8f3..6ea1f85a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ - +# Unreleased + + + +## Fixes +- Only raise error within `union_relations` for `build`/`run` sub-commands ([#606](https://github.com/dbt-labs/dbt-utils/issues/606), [#607](https://github.com/dbt-labs/dbt-utils/pull/607)) + + + + +## Contributors: +- [@jeremyyeo](https://github.com/jeremyyeo) (#606) + # dbt-utils v0.8.5 ## 🚨 deduplicate ([#542](https://github.com/dbt-labs/dbt-utils/pull/542), [#548](https://github.com/dbt-labs/dbt-utils/pull/548)) diff --git a/macros/sql/union.sql b/macros/sql/union.sql index 0d4ebccb..cb960484 100644 --- a/macros/sql/union.sql +++ b/macros/sql/union.sql @@ -60,7 +60,10 @@ {%- endfor -%} {%- set ordered_column_names = column_superset.keys() -%} + {%- set dbt_command = flags.WHICH -%} + + {% if dbt_command in ['run', 'build'] %} {% if (include | length > 0 or exclude | length > 0) and not column_superset.keys() %} {%- set relations_string -%} {%- for relation in relations -%} @@ -75,6 +78,7 @@ {{ exceptions.raise_compiler_error(error_message) }} {%- endif -%} + {%- endif -%} {%- for relation in relations %}