How to only build models that passed tests in the previous build?

Hi everyone,

I’m trying a new approach for data quality in our warehouse where we would build models on an audit schema and then build again on a prod schema, excluding models that failed the tests during the audit build.

For the 2nd build I tried with the command
dbt build --exclude 1+result:fail as mentioned in the doc but I’m getting the following error:

Internal Error
  No comparison run_results

which I don’t really understand since I actually have a run_results.json file stored in my /target folder.

dbt build --exclude 1+result:fail --defer --state ./target seems to work but I don’t really know why and I’m not sure it does the same thing, I still have to wrap my head around the defer method.

Does someone have an idea?

Thanks :slight_smile:

Without providing the --defer flag, dbt doesn’t try to defer to an old version. Likewise, without the --state flag, it doesn’t know where to look for the comparison manifest.

Is the correct command to run to successfully use the result method in your selector