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 questionsDomain Testing & documentation
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.
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. ---
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.
Keep practicing
Take the free DBT-ANALYTICS-ENGINEERING practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other DBT-ANALYTICS-ENGINEERING practice questions
- Question 1What is the purpose of the --resource-type argument in the dbt ls command?
- Question 2Select the valid methods for configuring incremental models in dbt. (Select all that appl…
- Question 3When fixing a dbt model issue, it is acceptable to skip the testing process in a separate…
- Question 5You discover that a dbt model is directly referencing a raw object in the database withou…
- Question 6What is the purpose of the dbt deps command in the dbt workflow?
- Question 7Which of the following commands will generate compiled SQL code and save it to the "targe…
