-
Notifications
You must be signed in to change notification settings - Fork 496
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
Change to union_relations in 0.8.1 causes error about no columns being found #505
Comments
Hi @andrewpblee, sorry for your trouble here! This is curious as during testing everything worked correctly. I'm wondering whether the absence of one or more of the include/exclude params behaves differently. Could you try one or both of these:
https://github.com/dbt-labs/dbt-utils/blob/main/macros/sql/union.sql#L64 I suspect that might restore the old behaviour - if it does then I'll ship another patch ASAP. Writing this on mobile which is why I'm delegating the debugging - thanks in advance for your help! |
hey @joellabes thanks - and no worries - i'll try the custom macro version first and see how that reacts |
It works! - I copied the macro into a new file, swapped out the line as you said and the github action passes with dbt utils at 0.8.1 |
OK! Thanks for doing the research. We'll get that properly released later today hopefully, at which point you can safely delete your version |
Thanks @joellabes, I'm intrigued why this is only happening within our github actions (we use sqlfluff and pre-commit-dbt and both errored) and not when I compile locally. |
Hmm! That is weird - we couldn't repro it here either. Can you share the columns in the models you're trying to union? Our only guess so far is something along the lines of "maybe the third model doesn't share any columns with the first one". |
Hello, happy to help contribute to get this issue resolved. We're also experiencing the exact same problem. |
@thisiscab thank you! In the short term, it looks like the workaround above will see you right - would appreciate any background you can share. Is yours also only happening with sqlfluff and other CI checks? Is there anything unexpected about the columns you're combining? Do you define a set of include/exclude values in any of your usages of the macro? |
Here is how we're using the the macro: {%- set table_that_contains_locations = [
ref('stg_chord__shopify_orders'),
ref('stg_chord__shopify_fulfillments'),
]
-%}
with source as (
select * from {{ source }}
),
all_location_ids_outside_main_table as (
{{ dbt_utils.union_relations(
relations=table_that_contains_locations,
include=[
chord_utils.target_casing('location_id'),
chord_utils.target_casing('created_at'),
]
) }}
),
... It's failing in our CI checks when running the command We've hard-coded the package's version |
hey @joellabes, so this is our activities one-big-table, that has everything a customer ever did with us, each activity must have a core fields in common (e.g |
@joellabes I am seeing similar issues in our dbt project @ Surfline. All started when I ran packages:
- package: calogica/dbt_date # This includes dbt-labs/dbt-utils
version: [">=0.5.0", "<0.6.0"]
- package: dbt-labs/dbt_utils # This is included due to a bug in union_relations for v0.8.1
version: 0.8.0
- package: dbt-labs/audit_helper
version: 0.5.0
- package: dbt-labs/codegen
version: 0.5.0 The SQL where this failed was
As a sanity check that it wasn't something upstream for our extract-load, I queried the underlying tables and they do have columns to union. |
@GClunies are you running into issues only in secondary CI contexts (e.g. SQLFluff and pre-commit-dbt) vs deployment, or is it impacting your main workflow as well? This is a weird one; I would prefer to understand it before fixing it, to be sure that we're actually fixing it, but since the workaround above protects users who aren't even using include/exclude, I think we'll ship that now and keep trying to track down the underlying issue. |
@joellabes I ran into it while developing locally. Error surfaced when running |
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! |
Describe 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:This error message looks like it was introduced in 0.8.1, which appears to amend how
include
andexclude
works, but our model does not use these fields, here it is:Steps to reproduce
With the following:
and packages:
Create a model using
union_relations
, and try to compile the codeExpected 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:version: 0.5.1
Which database are you using dbt with?
The output of
dbt --version
:Additional context
Looks related to this
column_superset.keys()
list from https://github.com/dbt-labs/dbt-utils/blob/main/macros/sql/union.sql#L64Happy 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?
The text was updated successfully, but these errors were encountered: