Run only changed models

I’m trying to run dbt run -s state:modified but I’m getting the error

22:38:24  Running with dbt=1.5.1
22:38:28  Found 22 models, 11 tests, 2 snapshots, 0 analyses, 2 macros, 10 operations, 1 seed files, 44 sources, 0 exposures, 0 metrics, 0 groups
22:38:28  Encountered an error:
Runtime Error
  Got a state selector method, but no comparison manifest

Let me know if I missed something in the docs about how to resolve this error but I’m not sure how to proceed

Hello @htz !

The state:modified method needs to compare your current manifest with another manifest

So you have to save the old manifest in a folder and pass the folder’s path to the state flag

$ dbt run --select model_b --defer --state prod-run-artifacts

The state method is used to select nodes by comparing them against a previous version of the same project, which is represented by a manifest. The file path of the comparison manifest must be specified via the --state flag or DBT_STATE environment variable.

1 Like

If you’re using dbt Cloud, it will handle providing the artifacts for deferral, you just have to pick which job/environment you want to defer to.

1 Like

Hey, @joellabes! Thanks for mentioning the differences with dbt cloud. Can you an provide an example dbt cloud command to accomplishes this? Specifically a command that would be used in a deployment job in the production environment. I’m still unsure if I need to include the --state or --defer flags in the command.

In dbt Cloud, you don’t need to specify either of these flags, your command can be as simple as dbt build --select state:modified+.

Check out Continuous integration jobs in dbt Cloud | dbt Developer Hub