-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Disabling package models by default leads to unexpected testing behavior #3043
Comments
Thanks @soltanianalytics! This is a tricky one. I think you've identified a real bug that exists at the intersection of tests, vars, packages, and model configs. I really appreciate the detailed write-up and reproduction case. For the specific use case you're describing, I'd recommend a different approach. Instead of using a variable ( models:
gemma_dbt_utils:
+enabled: true This config overrides any Since there's a reasonable workaround today, fixing this specific issue isn't going to be a huge priority, but I think we may end up with another indirect resolution. For the next version of dbt, we're planning work around tests, including the ability to enable or disable both schema and data tests from |
Thanks for the workaround! I'm staying with the one I described above, though. If I do it via root project, I would have two different places in the root where I'd have to make changes to activate the model (once in |
I just triaged a very similar issue (#3591), and I realized you had it right all along:
In older versions of dbt, tests were lumped in with project-level I confirmed by trying the setup described above with v0.20.0:
|
I very much appreciate you getting back to me with the update! |
Note: I suspect that this behavior is not intended, but I might be wrong, so feel free to close this issue if so.
Describe the bug
It seems that a package that disables all models by default and re-enables them via config and variables leads to disabled schema tests for enabled models.
Steps To Reproduce
I am developing a small package and am currently creating a model in this package. This model is called
gemma_fx.sql
. The first line of the model is{{ config(enabled=var("gemma:fx:enabled")) }}
.The model is also documented and has tests as follows:
The package's
dbt_project.yml
looks as follows:Therefore, I disabled the model by default, but any project that uses the model can activate the model by setting the variable
gemma:fx:enabled
totrue
.Very much like the dbt utils, I created an
integration_tests
subfolder where I install the package via symlink to develop and test it. That project'sdbt_project.yml
filevars
section looks like that:Running
dbt run
works properly. Runningdbt test
does not run the tests I have defined.Interestingly enough, if I delete the last line in the package's
dbt_project.yml
file,+enabled: false # models need to be activated on purpose
, it does work.Expected behavior
In the above setup, changing the last line of the package's
dbt_project.yml
file should have no effect, since the model is still disabled via variable by default and enabled by variable in the project that uses the package.I'd also prefer if this worked properly, because that way all models in the package can be disabled by default, with or without the use of variables.
System information
Which database are you using dbt with?
The output of
dbt --version
:The operating system you're using: Win 10
The output of
python --version
: Python 3.7.2The text was updated successfully, but these errors were encountered: