Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output '*' in union_relations when no columns are found in compile mode #832

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions macros/sql/union.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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] %}
Expand Down