-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[CT-2157][Regression] Bug between adapter.get_relation & dbt_utils._is_relation #7024
Comments
I can observe all of that, but have got no clue what to do with it. |
@patkearns10, thanks for doing all of that investigative work! I don't know that the issue is in |
@patkearns10 One more question, what's your quoting config set to? |
I do not have any quoting set in my project. And when I switch to all caps, still fails: ... This is actually weird though...
if I do those individually, it passes, |
@patkearns10 I added some tests to troubleshoot. They're on this PR: dbt-labs/dbt-snowflake#504. But I can't get the tests to fail. I believe this macro summarizes your issue: https://github.com/dbt-labs/dbt-snowflake/blob/3dd1d4ca6a8e28d68dd3883a529056046182c393/tests/functional/adapter/get_relation_tests/macros.py#L26. Does that look right? The test is basically executing the macro and seeing if it makes it through. The macro returns a valid |
The logic looks right to me, so, I would have expected that to fail based on what we were seeing last week. |
@patkearns10 I added some additional tests. It looks like I can get this to fail if I create a state where the macro can run before the model is created (if nothing is tied together, it all gets created in parallel with no dependencies). Additionally, I've gotten both un-quoted and quoted versions of the relation name based on those scenarios. Could you do me one more favor and run your scenario after wrapping the double-quoted schema and identifier in single quotes? In other words: {% set old_etl_relation=adapter.get_relation(
database=target.database,
schema='"DBT_PKEARNS"',
identifier='"CUSTOMERS"'
) -%}
{{ dbt_utils.get_filtered_columns_in_relation(from=old_etl_relation) }} |
I'm still facing this issue, did it get resolved? I see the above PR has passed tested but lacks a review and that was in March? |
Me too. Are there any news on this? Thank you. |
So the immediate way to fix this is by wrapping the call to {% set old_etl_relation=adapter.get_relation(
database=target.database,
schema="dbt_jcohen",
identifier="customers"
) -%}
{% if execute %} {# or if old_etl_relation #}
{{ dbt_utils.get_filtered_columns_in_relation(from=old_etl_relation) }}
{% endif %} The reason is that, at parse time, For my colleagues: Internal reference doc on the distinctions between parsing <> compilation" <> runtime (which I'm long overdue for turning into a public README in this repo). I am pretty sure this is not, in fact, a regression. I get the same error if I use dbt-core v1.1 + dbt-utils v0.8.4: -- models/my_models.sql
{% set old_etl_relation=adapter.get_relation(
database=target.database,
schema="dbt_jcohen",
identifier="customers"
) -%}
{{ dbt_utils.get_filtered_columns_in_relation(from=old_etl_relation) }}
I think there are two reasonable ways to fix this within
I'm going to open a new issue over there, and close this one. |
Closing in favor of: dbt-labs/dbt-utils#833 |
Is this a regression in a recent version of dbt-core?
Current Behavior
code snippets commonly used in the audit-helper workflow,
adapter.get_relation
now cause errors:get_relation
creates a relation from a fully qualified table namedbt_utils.get_filtered_columns_in_relation
macro, wheredbt_utils._is_relation
says this is not a relation.adapter._is_relation
(code)Expected/Previous Behavior
In a previous version, this returned no errors.
Steps To Reproduce
In latest version (or anything from dbt 1.2 & dbt_utils version: 0.9.0 onwards):
<replace schema and identifier with a table that does exist>
Swap to version dbt 1.1 & dbt_utils 0.84 and it will run successfully.
Relevant log output
Environment
Which database adapter are you using with dbt?
snowflake
Additional Context
Slack thread:
https://dbt-labs.slack.com/archives/C010X3HKX2L/p1676945381425329
So, it seems like this code:
to “get a relation” is returning a thing that
_is_relation
does not consider to be a relation.so we could fix
adapter.get_relation
to return something that_is_relation
agrees withor we could fix
_is_relation
to be more lenient, based on whateverget_relation
now returnsUsed some logic from this old issue to diagnose the
_is_relation
failure as well:Stealing some logic from this old PR: #2938
The text was updated successfully, but these errors were encountered: