Change to union_relations in 0.8.1 causes error about no columns being found
See original GitHub issueDescribe the bug
Today our activities model, which uses the union_relations macro, to stitch together a few models, has broken within our SQLFluff Github Action, with the following error:
TMP: dbt compilation error on file 'models/enrichment/en__activities.sql', There were no columns found to union for relations int__activities__customer_order_created, int__activities__non_customer_order_created, int__activities__order_adjusted, int__activities__order_line_created, int__activities__order_line_refunded
This error message looks like it was introduced in 0.8.1, which appears to amend how include and exclude works, but our model does not use these fields, here it is:
WITH
activities AS (
{{ dbt_utils.union_relations(
relations=[
ref('int__activities__customer_order_created'),
ref('int__activities__non_customer_order_created'),
ref('int__activities__order_adjusted'),
ref('int__activities__order_line_created'),
ref('int__activities__order_line_refunded')
]
) }}
)
....
Steps to reproduce
With the following:
dbt_core==1.0.*
dbt_snowflake==1.0.*
sqlfluff-templater-dbt==0.9.*
and packages:
packages:
- package: calogica/dbt_expectations
version: 0.5.1
Create a model using union_relations, and try to compile the code
Expected results
The model should compile without issue
Actual results
The compile fails, stating that there are no columns found in the relations
System information
The contents of your packages.yml file:
- package: calogica/dbt_expectations version: 0.5.1
Which database are you using dbt with?
- postgres
- redshift
- bigquery
- [ x ] snowflake
- other (specify: ____________)
The output of dbt --version:
installed version: 1.0.3
latest version: 1.0.3
Up to date!
Plugins:
- snowflake: 1.0.0 - Up to date!
Additional context
Looks related to this column_superset.keys() list from https://github.com/dbt-labs/dbt-utils/blob/main/macros/sql/union.sql#L64
Happy to share more info and screen grabs of our model and the underlying models, and from our github action as well (it’s basically running sqlfluff lint on changed files)
Are you interested in contributing the fix?
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (6 by maintainers)

Top Related StackOverflow Question
OK thanks! I’ve just released dbt_utils 0.8.2 which has a fix, so I’ll close this out. Sorry for the hassle all!
@joellabes I ran into it while developing locally. Error surfaced when running
dbt build -s +some_model --full-refresh