FlashGenius Logo FlashGenius
dbt Certification ยท Domain 6 of 6

dbt Analytics Engineering Certification โ€” State & Deployment

State selectors, dbt retry, result selectors, CI/CD with slim CI, and deployment environments โ€” the production operations layer of dbt.

~10%Exam Weight
Domain 8Official Domain
CI/CD FocusPractical
Final Domain6 of 6

What This Domain Covers

Domain 6 covers how dbt manages state โ€” knowing what changed between runs โ€” and how that enables efficient CI/CD pipelines, production job recovery, and slim builds that only process what's new or modified.

๐Ÿ“Š

State Selectors

Select models based on what changed since the last production run

๐Ÿ”

Result Selectors

Select based on outcome of the last run (error, warn, skip, pass)

โ†ฉ๏ธ

dbt retry

Re-run only failed + downstream nodes from the last run automatically

๐Ÿš€

Slim CI/CD

Run only changed models in PRs โ€” fast, cost-effective CI pipelines

The Slim CI Pattern

The most exam-tested deployment concept is Slim CI โ€” the pattern of running only changed models in CI rather than the full project:

PR opened
โ†’
Download prod artifacts
โ†’
dbt clone unchanged
โ†’
dbt build state:modified+
โ†’
Tests pass โ†’ merge

This pattern makes CI 10x faster by only rebuilding models that actually changed โ€” not the entire project.

๐ŸŽฏ Key Exam Insight

The exam tests two key concepts: (1) state:modified+ selects changed models AND their downstream dependencies โ€” the + is critical, without it you might miss testing a downstream model affected by your change. (2) dbt retry requires target/run_results.json to exist โ€” it reads the last run's results, so it must be run in the same environment/directory where the last run happened.

Key Concepts Deep Dive

๐Ÿ“Š
State Selectors
Select models based on what changed vs production
Very High Frequency โ–พ
SelectorWhat It Selects
state:newModels that exist in the project but don't exist in production artifacts
state:modifiedModels whose SQL or config changed since the last production run
state:modified+Modified models + all their downstream dependencies (the slim CI standard)
state:oldModels that exist in production but were removed from the project
  • State comparison requires production artifacts (manifest.json) from the last prod run
  • Pass the artifacts directory with --state ./path/to/artifacts
  • In dbt Cloud, artifacts are automatically available via the "defer to production" setting
๐Ÿ’ก state:modified detects changes to model SQL, config, tests, and schema definitions โ€” not just the model file itself.
๐Ÿ”
Result Selectors
Select based on last run outcome
High Frequency โ–พ
SelectorWhat It Selects
result:errorNodes that errored in the last run
result:error+Errored nodes + all their downstream dependencies
result:warnNodes that produced warnings
result:skipNodes that were skipped (due to upstream failures)
result:passNodes that passed (run or test)
  • Result selectors read from target/run_results.json
  • Combined with state selectors: --select result:error state:modified+
  • dbt retry is shorthand for dbt run --select result:error+ result:skip
๐Ÿ’ก result: selectors are about past outcomes. state: selectors are about code changes. They serve different purposes and can be combined.
โ†ฉ๏ธ
dbt retry
Smart recovery from production failures
High Frequency โ–พ
  • dbt retry re-runs all nodes that errored or were skipped in the most recent run
  • Reads target/run_results.json to determine which nodes need to be re-run
  • Skips nodes that already passed โ€” only re-runs failures and their downstream impact
  • Equivalent to: dbt run --select result:error+ result:skip+
  • Must be run in the same directory/environment where the original failing run happened
  • Commonly used in production job recovery: when a prod run fails at 3am, retry fixes it without a full rebuild
๐Ÿ’ก dbt retry is the fastest path to recovery after a partial failure. It avoids rebuilding the 80% of models that already succeeded.
๐Ÿš€
Deployment Environments & CI/CD
Dev โ†’ staging โ†’ production workflow
Medium Frequency โ–พ
  • Development โ€” each developer has their own schema (dev_username); changes are isolated
  • CI (staging) โ€” PR environment; builds only changed models against production artifacts
  • Production โ€” runs on a schedule; builds the full project (or all changed models)
  • dbt Cloud environments define target, credentials, and scheduling per environment
  • Defer to production โ€” dev and CI can reference production models for unchanged upstream dependencies instead of rebuilding them
  • Threads configuration determines parallelism โ€” more threads = faster runs on non-dependent models
๐Ÿ’ก Defer to production means developers can run a single changed model and have it join against production data for the upstream tables they didn't touch.
โšก
Combining State + Result Selectors
Advanced selection for complex scenarios
Medium Frequency โ–พ
  • Selectors can be combined with AND logic using spaces: --select result:error state:modified+
  • Selectors can use OR logic with commas: --select result:error,result:skip
  • Example: re-run errored models that are also in a specific tag: --select result:error,tag:daily
  • Example: run modified models + expose to all their downstream consumers: --select state:modified+
  • The state selector requires --state flag pointing to production artifact directory
๐Ÿ’ก In CI jobs: dbt build --select state:modified+ --state ./prod-artifacts is the standard slim CI command. Memorize this pattern.

Domain 6 Study Checklist

Progress: 0 / 10 complete
โœ“
Concept

Know all 4 state selectors: new, modified, modified+, old

Understand what each selects and when to use each in a CI pipeline

โœ“
Concept

Know all result selectors: error, warn, skip, pass

Understand what each selects and the role of run_results.json

โœ“
Exam Prep

Understand what dbt retry does and what it requires

Requires run_results.json; re-runs error + skip nodes from last run

โœ“
Exam Prep

Know the slim CI command: dbt build --select state:modified+ --state ./artifacts

This is the standard pattern โ€” know it cold

โœ“
Concept

Understand what production artifacts are and why they're needed for state

manifest.json from last prod run is compared against current project state

โœ“
Concept

Understand "defer to production" in dbt Cloud

Dev and CI reference production models for unchanged upstream dependencies

โœ“
Practice

Run a job that fails, then use dbt retry to recover

Verify only the failed + downstream models are re-run

โœ“
Concept

Understand the three environments: dev, CI, prod

Know what runs in each and how data flows through them

โœ“
Exam Prep

Know that state:modified includes changes to model SQL, config, and tests

Not just the .sql file โ€” schema changes trigger modified too

โœ“
Exam Prep

Read "The state selector" documentation page on docs.getdbt.com

Review all selector types and the --state flag requirement

Quick Reference

Slim CI Job (PR Build)

# In your CI job config: # 1. Download prod artifacts # 2. Run only changed models dbt build \ --select state:modified+ \ --state ./prod-artifacts \ --target ci # Also build new models: dbt build \ --select state:new state:modified+ \ --state ./prod-artifacts

Result Selectors

# Re-run all errors + downstream dbt run --select result:error+ # Re-run errors and skipped dbt run \ --select result:error,result:skip # Shorthand for above: dbt retry # Combine state + result: dbt run \ --select result:error \ --select state:modified+ \ --state ./artifacts

dbt retry

# Simple retry after failure dbt retry # Must be in same directory as # the original failing run # (needs target/run_results.json) # Equivalent manual command: dbt run \ --select result:error+ \ --select result:skip

State Selector Reference

state:new # new models state:modified # changed models state:modified+ # changed + downstream state:old # removed models # Requires --state flag: --state ./path/to/prod/artifacts # Artifacts needed: manifest.json # (from dbt docs generate or # dbt ls with compile)

dbt Cloud Deployment Setup

# Environment configuration # (in dbt Cloud UI) # Development: target: dev schema: dev_{{ env_var('DBT_USER') }} # CI: target: ci schema: pr_{{ env_var('PR_NUMBER') }} # Production: target: prod schema: analytics

Artifacts for State

# Artifacts are in target/: target/ manifest.json # project graph run_results.json # last run outcome catalog.json # warehouse metadata # For state comparison: # โ†’ need manifest.json from PROD # For dbt retry: # โ†’ need run_results.json locally

Domain 6 Practice Quiz

5 questions on state, retry, and deployment.

Domain 6 Study Plan

3โ€“4 days to cover state, retry, and CI patterns.

Days 1โ€“2 ยท State Selectors

  • Read "The state selector" documentation page thoroughly
  • Generate production artifacts with dbt docs generate
  • Run dbt ls --select state:modified --state ./prod-artifacts and observe what's selected
  • Make a change to one model and re-run โ€” verify state:modified picks it up

Days 3โ€“4 ยท Retry & CI Patterns

  • Intentionally break a model mid-DAG, let the run fail, then use dbt retry
  • Verify only failed + downstream models re-run (not the entire project)
  • Study the Advanced Deployment course on learn.getdbt.com
  • Understand how dbt Cloud's "defer to production" enables lean development

Final Review ยท All Domains

  • Take a full 65-question practice exam (simulate real conditions)
  • Review any domains where you scored below 65%
  • Re-read the official study guide's "Learning Path" checkpoints
  • Do 10โ€“15 questions specifically on Domain 6 state and retry topics

Common Exam Mistakes โ€” Domain 6

1

Using state:modified without the + modifier in CI

Missing downstream impact of changes

โ–พ
What Goes Wrong

state:modified selects only the changed model itself. If you change stg_orders, fct_orders (which depends on it) is NOT selected and won't be tested in CI. You might merge a breaking change without knowing.

The Fix

Always use state:modified+ in CI pipelines. The + ensures all downstream dependencies of changed models are also built and tested, catching cascading failures.

๐Ÿ›ก๏ธ Slim CI standard: state:modified+ not state:modified. The + is not optional in CI.
2

Running dbt retry in the wrong directory

retry needs run_results.json from the failed run

โ–พ
What Goes Wrong

dbt retry reads target/run_results.json. If you run it from a different directory, or the previous run's artifacts were cleaned, retry fails with "no run results found".

The Fix

Run dbt retry in the same project directory where the original failing run happened, ensuring target/run_results.json is still present. In dbt Cloud, retry is available directly from the run UI.

๐Ÿ›ก๏ธ dbt retry = "retry from THIS machine's last run". It's local context-dependent.
3

Thinking state comparison uses run_results.json

State uses manifest.json, not run_results.json

โ–พ
What Goes Wrong

Candidates confuse the artifacts needed for state selectors vs result selectors. State comparison needs manifest.json (from the last production run). Result selectors need run_results.json (from the last run in the current directory).

The Fix

State selectors (state:modified) โ†’ need production manifest.json via --state flag. Result selectors (result:error) โ†’ read local target/run_results.json automatically.

๐Ÿ›ก๏ธ state: needs manifest.json (code comparison). result: needs run_results.json (outcome comparison).
4

Not including state:new in slim CI

New models aren't "modified" โ€” they won't be selected

โ–พ
What Goes Wrong

A developer adds a new model. state:modified only selects models that EXIST in both the current project and the production artifacts and have changed. New models are not in the production artifacts, so they're not "modified".

The Fix

Use both: --select state:new state:modified+. This ensures new models AND modified models (with their downstream) are all built and tested in CI.

๐Ÿ›ก๏ธ Complete slim CI selection: state:new state:modified+ โ€” covers both new and changed models.
5

Confusing environments with targets

Environments and targets are related but distinct

โ–พ
What Goes Wrong

Candidates conflate dbt Cloud environments (dev, CI, prod) with the --target flag in profiles.yml. They're related but different: environments are dbt Cloud concepts; targets are connection profiles.

The Fix

A dbt Cloud environment defines the credentials, schema, and target name for a deployment context. The --target flag selects which profile to use when running locally. They serve the same conceptual purpose but at different levels.

๐Ÿ›ก๏ธ dbt Cloud environment โ†’ UI configuration. --target โ†’ CLI/profiles.yml selection.

Frequently Asked Questions

What does "defer to production" mean in dbt Cloud? +
"Defer to production" allows developers in a dev environment to reference production models for any upstream dependencies they haven't changed. Instead of needing to build the entire project locally, a developer working on one model can reference production's version of all the upstream models, saving significant time and compute. This is configured per environment in dbt Cloud.
What file does the --state flag point to? +
The --state flag points to a directory containing the production manifest.json file (not the file itself). dbt reads the manifest.json from that directory to compare the current project's state against the last production run. In dbt Cloud CI jobs, this is typically fetched automatically from the production environment's last successful run.
What triggers state:modified? Only .sql file changes? +
No โ€” state:modified detects changes to: the model's SQL content, the model's config (materialization, tags, grants, etc.), tests defined for the model, and schema/column definitions. Any of these changes will mark a model as modified. This is why it's comprehensive for CI โ€” even a config change without SQL changes triggers the model to be re-built and re-tested.
How is dbt retry different from just re-running the full job? +
dbt retry only re-runs the nodes that failed (ERROR) or were skipped (SKIP) in the previous run. It does NOT re-run nodes that already succeeded. This makes recovery faster and avoids redundant compute โ€” if 90% of models succeeded, retry only touches the 10% that didn't.
Can you combine state and result selectors in one command? +
Yes โ€” you can use multiple --select flags to combine selectors. For example: dbt build --select state:modified+ result:error --state ./artifacts. The two selectors are combined with AND logic, selecting nodes that are BOTH modified AND errored. Use commas for OR logic: --select result:error,result:skip.
What happens to skipped nodes in a retry? +
Skipped nodes are included in dbt retry because they were skipped due to upstream failures โ€” not because they're healthy. When retry fixes the upstream error and re-runs it, the previously skipped nodes need to run too. This is why the equivalent manual command is --select result:error+ result:skip โ€” both error and skip nodes need to be addressed.
Official Resources

Domain 6 Study Resources

Advanced deployment course and state selector docs