dbt run
Builds models (and related materializations like incremental tables). It does not run tests, seeds, or snapshots by itself.
dbt build
Runs a unified of resources in dependency order: seeds, snapshots, models, and tests. A test that depends on a model runs after that model succeeds. If an upstream resource fails, downstream work for that branch is skipped.
dbt run → models (create/replace/merge SQL)
dbt build → seed → snapshot → model → test (in DAG order)
(and skip children when a parent fails)When to use which
- `dbt run`: quick iteration while developing a model; you will test separately.
- `dbt build`: CI and production jobs where you want "build then prove quality" as one graph.
- `dbt test`: run tests only (assumes models already exist).
Example
dbt run --select stg_orders+ # models only
dbt build --select stg_orders+ # models + their tests (and more if selected)Interview tip: Prefer dbt build in pipelines: it fails fast on bad data and respects test nodes as first-class DAG citizens, not a separate afterthought script.
What changes when a test fails
Say stg_orders has a unique test on order_id, and tonight's load contains a duplicate. With dbt run and then dbt test, both stg_orders and fct_orders are built from the bad rows, and you only learn about it afterwards. With dbt build, stg_orders is built, its test fails, and fct_orders and everything after it are skipped, so the last good version stays in place. The failed model itself is still created, because a test can only run after its model exists. build protects what comes after the failure, not the node that failed.
Seeds and snapshots also run during dbt build, so a large seed slows every build. Use --select so a build touches only what changed.