Skip to content

Fixing and testing a change before it merges

Once a bug in a dbt model is diagnosed, the fix must be developed in a feature branch and validated locally before merging to a protected branch (e.g., main). This involves rerunning the affected model(s), checking dependent models and tests, and confirming the fix resolves the issue without introducing regressions.

1 · Learn the must-know

  • Use dbt run --select model_name+ to rebuild the fixed model and all downstream dependents, ensuring the fix doesn't break anything relying on it.
  • Use dbt build --select model_name+ to run and test the model and its downstream dependents together in dependency order, catching both data and logic regressions.
  • Always develop against a dev/staging target (a separate schema or database) so fixes are validated without impacting production data.
  • Re-run dbt test on the changed model and related models to confirm existing generic and singular tests pass after the fix.
  • Check compiled SQL (in the target/compiled directory) to verify the fix produces the intended logic before executing against the warehouse.
  • Open a pull request only after local dbt build/dbt test runs are green; CI jobs (e.g., via a configured CI pipeline) should also pass before merging.

2 · Check your understanding

Check this objectiveFree · always available

The following test on fct_orders starts failing after a source system change: models: - name: fct_orders columns: - name: order_id tests: - unique: config: store_failures: true After rerunning dbt test --select fct_orders, where should you look to find the specific order_id values that are duplicated, so you can diagnose the bug before writing a fix?

Your objective map0 tried · 0 answered correctly · 31 untouched

What you have tried across dbt Analytics Engineering's objectives, not a readiness score.

Developing and optimizing dbt models45.16% of the exam*0 of 14 tried
Managing dbt models governance9.68% of the exam*0 of 3 tried
Debugging data modeling errors16.13% of the exam*0 of 5 tried
Troubleshooting and optimizing dbt pipelines6.45% of the exam*0 of 2 tried
Implementing dbt tests9.68% of the exam*0 of 3 tried
Implementing and maintaining external dependencies6.45% of the exam*0 of 2 tried
Leveraging the dbt state6.45% of the exam*0 of 2 tried

* Our estimate. dbt Labs publishes no section weights.

3 · Keep going