I’m doing some local testing using dbt core and trying to figure out how to only rerun models associated with failed tests from the prior dbt build invocation.

I’ve setup a test scenario with 3 models (models a, b, and c). I ran dbt build. The models were built and tests were run. The scenario has a failed not_null test, which impacts models a and c.

Now, I want to rerun only the models associated with the failed test (a and c), without having to manually select them.

I tried doing dbt build --select 1+result:fail which I found here. That resulted in

Encountered an error: No comparison run_results 

I also tried dbt build –-select result:error+ –-defer -–state ./target which I found here. That resulted in

dbt: error: unrecognized arguments: –-select result:error+ –-defer -–state ./target 

I’m guessing running only models impacted by failed tests relies on run_results.json which I see in ./target. So, I'm thinking I’m missing some kind of configuration step, but I’m having a hard time finding info on how to rerun dbt from the point of failure. Any suggestions or resources for this issue?

1

1 Answer

Ok, I ended up having some unnoticed em dashes in the second command I tried. This is what I was after

dbt build --select 1+result:fail+ --defer --state ./target 

Answered in dbt slack.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.