dbt-labs / dbt-core

dbt enables data analysts and engineers to transform their data using the same practices that software engineers use to build applications.
https://getdbt.com
Apache License 2.0
9.63k stars 1.59k forks source link

Support deferred tests #2701

Closed jtcohen6 closed 3 years ago

jtcohen6 commented 4 years ago

Describe the feature

In general: It may be desirable to test changes to a test without needing to first run the models it selects from:

dbt test -m my_new_test --defer --state path/to/artifacts

The resources that my_new_test depend on are not selected, and as such, references to those resources will be deferred to the supplied manifest's namespace.

For "Slim CI": In order to execute new tests that reference old unchanged models, we'll need to be able to:

dbt test -m state:modified+ --defer --state path/to/artifacts

If a model has been modified, this should run tests against the new model. If a test is new/modified, but the model it selects from is not, this should run tests against the deferred model.

This is intuitively tricky for relationships tests or data tests which depend on multiple models. If one model is included in the node selection criteria, and another model is not included, the test should defer only the latter's reference.

The only open question for me is: What should full test do?

dbt test --defer --state path/to/artifacts

Are all model nodes selected here?

Describe alternatives you've considered

jtcohen6 commented 4 years ago

The gap we planned to fill with dbt test --defer is better addressed with selectors. In particular, see discussion in #2704. Closing this issue and its corresponding PR (#2706) in the meantime.