diff --git a/CHANGELOG.md b/CHANGELOG.md index 3586c3e4..0efb38cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,16 @@ # Unreleased -**Full Changelog**: https://github.com/dbt-labs/dbt-utils/compare/1.3.0...main +**Full Changelog**: https://github.com/dbt-labs/dbt-utils/compare/1.4.0...main + +# dbt utils v1.4.0 + +* union_relations macro now outputs `*` in compile mode when the upstream relations haven't been built, such as when running SQLFluff on new models + +## New Contributors + +* @martinshjung made their first contribution in https://github.com/dbt-labs/dbt-utils/pull/832 + +**Full Changelog**: https://github.com/dbt-labs/dbt-utils/compare/1.3.0...1.4.0 # dbt utils v1.3.0 diff --git a/macros/sql/union.sql b/macros/sql/union.sql index ac289e2f..0d1f8961 100644 --- a/macros/sql/union.sql +++ b/macros/sql/union.sql @@ -103,6 +103,12 @@ cast({{ dbt.string_literal(relation) }} as {{ dbt.type_string() }}) as {{ source_column_name }}, {%- endif %} + /* No columns from any of the relations. + This star is only output during dbt compile, and exists to keep SQLFluff happy. */ + {% if dbt_command == 'compile' and ordered_column_names|length == 0 %} + * + {% endif %} + {% for col_name in ordered_column_names -%} {%- set col = column_superset[col_name] %}