-
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
[Feature] Enable unit testing for models that use adapter.get_relation
#10891
Comments
Maybe has the same cause as #10139. This part
should be working because is covered by a functional test on dbt-core dbt-core/tests/functional/unit_testing/fixtures.py Lines 302 to 304 in a0674db
|
Yes, the {{this}} works as mentioned |
I think this is a limitation of unit tests already pointed here in some reported bugs. We should have an option to override dynamic variables in jinja template like this
|
For duckdb I got a different error msg
The model works fine without unit test. I think like I said before and discussed here #10908 maybe is a good idea to be able to easy override a dynamic var |
Thanks for reporting this @mithungame ! Overall this isn't a bug, but rather a known limitation. Namely, you can't run introspective queries on the given inputs to unit tests. So I'm going to convert this to a feature request for further consideration. I believe this particular request to utilize
|
adapter.get_relation
Is this a new bug in dbt-core?
Current Behavior
Currently we have an existing macro where we alter SQL behavior based on presence or absence of a model
The code works fine without any issue
When trying to unit test this model it fails with below error
'str object' has no attribute 'database'.
narrowed it down to usage of the below line
{%- set relation = adapter.get_relation(this.database, this.schema, this.table) -%}
Expected Behavior
The "this" in adapter is treated as a string rather than a relation .
using
{{ this }}
in schema yml is not possiblethe "this" inside adapter relation should be a relation
Steps To Reproduce
create below model and unit test
Relevant log output
Environment
Which database adapter are you using with dbt?
snowflake
Additional Context
No response
The text was updated successfully, but these errors were encountered: