diff --git a/CHANGELOG.md b/CHANGELOG.md index 16e296f7..5b31e2da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ * Use QUALIFY clause in `deduplicate` macro for Redshift by @yauhen-sobaleu in https://github.com/dbt-labs/dbt-utils/pull/811 * get redshift external tables by @brendan-cook-87 in https://github.com/dbt-labs/dbt-utils/pull/753 * Equality test will now raise an error when the second model has less columns than the first by @rlh1994 in https://github.com/dbt-labs/dbt-utils/pull/765 +* union_relations macro now outputs '*' in compile mode when the upstream relations haven't been built, such as when running SQLFluff on new models ### Documentation @@ -43,6 +44,7 @@ * @yamotech made their first contribution in https://github.com/dbt-labs/dbt-utils/pull/876 * @PChambino made their first contribution in https://github.com/dbt-labs/dbt-utils/pull/853 * @pruoff made their first contribution in https://github.com/dbt-labs/dbt-utils/pull/856 +* @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.1.1...1.2.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] %}