0
0
dbtdata~10 mins

Slim CI with state comparison in dbt - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Slim CI with state comparison
Start: Trigger CI
Fetch current state
Fetch previous state
Compare states
Run only [Skip run
Report results
End
The CI process fetches current and previous states, compares them, runs only changed models if any, otherwise skips, then reports results.
Execution Sample
dbt
dbt run --state ./target
# Compares current models with previous run
# Runs only changed models
This command runs dbt models selectively by comparing current state with previous state to speed up CI.
Execution Table
StepActionCurrent StatePrevious StateComparison ResultCI Action
1Fetch current statemodels: A, B, CN/AN/APrepare for comparison
2Fetch previous statemodels: A, B, Cmodels: A, B, CN/AReady to compare
3Compare statesmodels: A, B, Cmodels: A, B, CNo changes detectedSkip model runs
4Report resultsN/AN/ANo models runCI passes quickly
💡 No changes detected, so CI skips running models to save time.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
current_stateemptymodels: A, B, Cmodels: A, B, Cmodels: A, B, Cmodels: A, B, C
previous_stateemptyemptymodels: A, B, Cmodels: A, B, Cmodels: A, B, C
comparison_resultnonenonenoneno changesno changes
ci_actionnonenonenoneskip runsskip runs
Key Moments - 2 Insights
Why does the CI skip running models even though the command 'dbt run' was executed?
Because the comparison_result in the execution_table at step 3 shows 'No changes detected', so the CI action is to skip running models to save time.
What happens if the previous state is missing or empty?
If previous_state is empty, the comparison cannot detect changes, so CI will run all models by default to ensure correctness.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 3, what is the comparison result?
ANo changes detected
BModels A and B changed
CPrevious state missing
DAll models changed
💡 Hint
Check the 'Comparison Result' column in row 3 of the execution_table.
At which step does the CI decide to skip running models?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Look at the 'CI Action' column in the execution_table to find when 'skip runs' happens.
If a model changed between states, how would the CI action change in the table?
ACI would skip running models
BCI would run only changed models
CCI would run no models
DCI would run all models regardless
💡 Hint
Refer to the concept_flow where changed models trigger running only those models.
Concept Snapshot
Slim CI with state comparison:
- Fetch current and previous states
- Compare models for changes
- Run only changed models if any
- Skip runs if no changes
- Saves CI time and resources
Full Transcript
Slim CI with state comparison is a process where the continuous integration system fetches the current state of dbt models and compares it with the previous state. If no changes are detected, the CI skips running models to save time. If changes exist, only those changed models run. This approach speeds up CI by avoiding unnecessary runs. The execution table shows steps from fetching states, comparing, deciding CI action, and reporting results. Variables track the states and decisions. Key moments clarify why skipping happens and what if previous state is missing. The quiz tests understanding of comparison results, decision steps, and CI actions based on changes.