DBT-ANALYTICS-ENGINEERING practice question 4 of 35

You want to run tests on only the models that have been modified since your last dbt run. Which command should you use?

Full set: 409 questions

Domain Testing & documentation

Answer options
A: dbt test --models
B: dbt test --state
C: dbt test --modified
D: dbt test --select state:modified Correct answer
Correct Answer:
D. dbt test --select state:modified
Explanation

The command dbt test --select state:modified leverages dbt's state comparison feature to identify and test only the models that have been modified. This requires providing a comparison manifest from a previous run (e.g., your last production run) using the --state flag. The state:modified selector then instructs dbt to find all models whose configurations or code have changed relative to that manifest. By default, dbt will also select and test the children of these modified models to ensure downstream dependencies are not broken. This method is fundamental to implementing "Slim CI" for faster, more efficient testing in development and deployment pipelines.

Why Incorrect

A. dbt test --models This is an incomplete command. The --models flag is a selector that requires an argument (e.g., a model name) to specify which models to test; it does not inherently select based on modification status.
B. dbt test --state The --state flag is necessary to provide the path to a comparison manifest, but it does not perform any selection on its own. It must be used with a state: selector like state:modified.
C. dbt test --modified This is a shorthand flag for --select state:modified. While it produces the same result, option D is the more explicit and canonical syntax recommended for clarity and consistency in modern dbt projects. ---

References

1. dbt Labs Official Documentation

"State selection method": This document explicitly details the state:modified selector. It states

"The modified value will select all resources that have been modified since the state manifest was generated." It also clarifies the prerequisite: "You must pass the --state flag for any state: selection to work."

Source: dbt Docs

dbt-core -> Reference -> Node selection -> State selection method.

2. dbt Labs Official Documentation

"About state": This page explains the purpose of the --state flag and the manifest.json file

which are the foundation for state-based selection. It notes

"By comparing your current project's files against the manifest.json from a previous run

dbt can determine what has changed."

Source: dbt Docs

dbt-core -> Guides -> Best practices -> About state.

3. dbt Labs Official Documentation

"test command": The documentation for the dbt test command lists the available flags and selectors

including --select and --state

confirming their role in constructing the correct command. It also lists --modified as a "selector flag."

Source: dbt Docs

dbt-core -> Reference -> dbt command reference -> test command.

Scroll to Top