Open SimonCarryer opened 1 month ago
I see what you are saying @SimonCarryer 👍
Specifically, both generic and singular data tests are disabled when they depend on a model that is disabled, and you'd like unit tests to behave the same way. This looks like the expected behavior to me though, so I'm going to update this to a feature request for further consideration.
We should also consider unit tests through the lens of indirect selection for data tests.
This is similar to https://github.com/dbt-labs/dbt-core/issues/9109, but distinct.
Oh no! As best I can tell, unit tests on disabled models are already disabled. The issue is that if the model is disabled by a macro, rather than in plain text, then the unit test is still compiled (and causes a compilation error).
The example in https://github.com/dbt-labs/dbt-core/issues/10540#issuecomment-2278217616 just disables the model in YAML like this (which uses plain text rather than a macro):
models:
- name: my_cool_report
config:
enabled: false
And it leaves all the unit tests related to that model as enabled and gives the compilation error you mentioned. Are you seeing something different? i.e., do you have an example where the unit test is disabled?
As an aside, when I disable a model using {{ config(enabled=false) }}
within the model definition rather than YAML, I get a Parsing Error rather than a Compilation Error:
Parsing Error
Unable to find model 'my_project.my_cool_report' for unit test 'my_cool_unit_test' in models/_unit_tests.yml
Is this a new bug in dbt-core?
Current Behavior
If a model is set to disabled by a macro (for example the standard
config
macro), then the enabled status is not known at compile time, and unit tests for the model are still compiled. This causes a compilation error:Expected Behavior
Usually, if a model is disabled (i.e.
enabled: false
), then unit tests which test that model are not compiled.Steps To Reproduce
{{config(enabled=false)}}
)Relevant log output
No response
Environment
Which database adapter are you using with dbt?
postgres
Additional Context
No response