-
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
Variables not picked up by tests #3564
Comments
Thanks for the quick report @Limess! I was able to reproduce this locally. Given that this works if I pass the
This appears to be a bug with the rendering context used for test arguments here: That comes from: It looks like we're pulling in I'm hopeful that this is a quick fix, and something we could easily include in a patch release. |
We are experiencing the same issue when testing an upgrade to dbt .20 as it's very common behavior for us to use vars defined in dbt_project.yml in our tests. An example of a test that is failing for us:
Sorry, it doesn't seem to be preserving the appropriate indentation, but the indentation is correct in the .yml file. |
@kwigley could you please look into this and see what might have caused the regression? |
Thanks for the issue report @Limess! The I think we just need to use a context that includes project defined vars when rendering the configs. Will add a fix to address this! I confirmed that |
hey @codigo-ergo-sum, I wasn't able to reproduce this. Are you getting the same compilation error when using Also, just a helpful tip. You can use triple back-ticks (```) instead of a single back-tick (`) to preserve code formatting and indentation! Hope that helps ``` asdf code indent ``` |
hi @kwigley , sorry, I'm not following. Can you clarify what you mean by "test arguments"? Thank you! |
Ya, sure thing! For "test arguments" I mean the values you pass to the test (a.k.a. the arguments you configure to pass to the test macro). As opposed to "test configs" (docs), which are also provided as properties of the test. So for the snippet you provided:
I tried to reproduce this compilation error with |
@codigo-ergo-sum I was able to reproduce @Limess's original issue, and when I saw you post in the slack thread, I connected it with this issue. Per @kwigley's explanation, it sounds like these are subtly different. Using dbt v0.20.0, I haven't been able to reproduce this error using the code snippet you included above. If I define a model named version: 2
models:
- name: my_model
tests:
- dbt_utils.expression_is_true:
severity: warn
tags:
- known_fail_or_warn
expression: "parent_classification IN ('Revenue', 'Expense')"
condition: "dim_financial_account_key <> {{ var('unknown_key') }}" And define a default value for that variable in
I can run I am able to yield that error if I move the call to |
Got it thanks @jtcohen6 . Now I understand @kwigley 's previous comments and the distinction between test arguments and test configs, my fault for not reading more closely. I went back and looked some more, and it turns out that in the same .yml file where I have the snippet above regarding the
By commenting this out, I was able to successfully compile the .yml file in question even with the other references to So my problem was also with the test configs and not with the test arguments, so I think we are good for the fix already done in #3646 . Thank you! |
Whoops! Merging my PR automatically closed the issue, I meant to follow up and make sure this was resolved for you. Glad #3646 will do the trick 👍 |
Describe the bug
Compilation fails when using variables defined in dbt_project.yaml in tests.
This was working prior to the upgrade to 0.20.0
Steps To Reproduce
Variable in dbt_project.toml
Test:
Expected behavior
The variable to be used from dbt_project.toml
Screenshots and log output
System information
Which database are you using dbt with?
The output of
dbt --version
:The operating system you're using:
Mac OS big Sur 11.2.3
The output of
python --version
:3.8.5
The text was updated successfully, but these errors were encountered: