Skip to content
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

Command which 'run's, then 'test's (in the same command). #2234

Closed
doctoryes opened this issue Mar 23, 2020 · 6 comments
Closed

Command which 'run's, then 'test's (in the same command). #2234

doctoryes opened this issue Mar 23, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@doctoryes
Copy link

Describe the feature

On a large DBT project with many sources/models, DBT startup time affects development velocity when iterating on models. A common development pattern is to dbt run -m <mymodel>, immediately followed by (if the run succeeds) dbt test -m <mymodel>. A dbt run_then_test command (with a better name/design?) would be nice, which - in the context of a single DBT command - both runs and tests the model, saving the startup time of the dbt test.

Describe alternatives you've considered

I'm unaware of any alternatives here. This sort of functionality would need to be within DBT itself.

Additional context

Although a similar issue exists here:
#1054
this issue is different. I'm not asking for the results of the dbt run to be rolled-back if dbt test fails, which is typically unnecessary while iterating in development.

Who will this benefit?

This feature would aid any developers who are iterating on models for a large-scale DBT project that has significant DBT startup time overhead (~30-60 seconds).

@doctoryes doctoryes added enhancement New feature or request triage labels Mar 23, 2020
@doctoryes doctoryes changed the title Command which runs, then tests (in the same command). Command which 'run's, then 'test's (in the same command). Mar 23, 2020
@drewbanin drewbanin removed the triage label Mar 26, 2020
@drewbanin
Copy link
Contributor

Thanks for opening @doctoryes! We're still thinking about the exact mechanism we should employ here, but I very much buy this use-case and it's one that I'm keen to support!

@drewbanin
Copy link
Contributor

drewbanin commented May 11, 2020

To implement this feature, let's add a flag --test to the dbt run subcommand. If the --test flag is provided, then dbt should run tests for the selected models in DAG order during the run.

Notes:

  • Only tests whose entire set of parents are selected in the run should be included. ie: this should not select a relationships test with one parent model selected and one parent model unselected.
  • If a test fails with error-level severity, then all of the dependents of the failed model should be skipped. If a test has more than one parent, then the children models of all ref'd parents should be skipped.
  • If a test fails with warning-level severity, then the run should proceed, but note that the --warn-error flag can elevate test warnings to failures. Note: The --warn-error flag should also be included as a flag to dbt run for the purposes of this feature

@drewbanin drewbanin added this to the Marian Anderson milestone May 13, 2020
@jtcohen6 jtcohen6 modified the milestones: Marian Anderson, 0.19.0 Aug 6, 2020
@jtcohen6 jtcohen6 removed this from the Kiyoshi Kuromiya milestone Sep 21, 2020
@automagic
Copy link

automagic commented Nov 4, 2020

Would it make sense to also specify --data so that we can run both schema and data tests inline? i.e --test --data or --data --test independently as part of the run command?

@jtcohen6
Copy link
Contributor

jtcohen6 commented Nov 5, 2020

That's a great question, which I would take a step further: how should we be passing task-specific flags to a generalized command? As I noted in #2743, this is even trickier for same-named flags that do subtly different things depending on the task type.

@fabrice-etanchaud
Copy link

Hello ! Having a little time to get back to dbt, I read only today that thread, and would like to suggest this link to our discourse design by contrat. this could help clarify (imho) the "build" idea. I tried to figure out how to add to dbt not only code testing, but mainly correctness validation.

@jtcohen6
Copy link
Contributor

This was partially resolved by the addition of dbt build in #3490. There's one more piece here which is still TK: failing tests blocking downstream models from running. Closing in favor of #3597

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants