Data Engineering  /  dbt

๐Ÿ”„ dbt โ€” Data Build Tool 60 guides ยท updated 2026

Analytics engineering with SQL โ€” models, tests, sources, and Jinja macros that turn raw warehouse tables into trustworthy, documented data products.

dbt build Command: Running Models, Tests, and Snapshots in One Go

Running dbt seed, then dbt snapshot, then dbt run, then dbt test as four separate commands works, but it has a real gap: nothing stops a broken model from being fully built and then having its downstream dependents build on top of it, before the test that would have caught the problem ever runs. dbt build closes that gap by interleaving every resource type โ€” seeds, models, snapshots, and their tests โ€” in a single dependency-ordered execution.


What Makes dbt build Different From Separate Commands

Terminal window
# The older pattern โ€” four separate passes over the DAG
dbt seed
dbt snapshot
dbt run
dbt test
# vs. one interleaved pass
dbt build

The critical difference isnโ€™t convenience โ€” itโ€™s failure containment. With separate commands, dbt run builds the entire DAG before dbt test gets a chance to flag that stg_orders produced bad data; every model downstream of stg_orders has already built on top of the bad data by the time testing happens. With dbt build, if stg_orders fails its tests, dbt stops before building anything downstream of it in the same run.

1 of 12 START sql table model staging.stg_orders ........ [RUN]
1 of 12 OK created sql table model staging.stg_orders .... [SELECT 48213 in 1.1s]
2 of 12 START test unique_stg_orders_order_id ............ [RUN]
2 of 12 FAIL 3 unique_stg_orders_order_id ................ [FAIL 3 in 0.4s]
3 of 12 SKIP relation model core.customer_orders ......... [SKIP]
4 of 12 SKIP relation model marts.sales_summary .......... [SKIP]

Models 3 and 4 are marked SKIP โ€” dbt recognized that they depend (directly or transitively) on the model that just failed its test, and declined to build on top of known-bad data.


Selection Works Identically to dbt run

Terminal window
dbt build --select stg_orders+
dbt build --select tag:finance
dbt build --exclude resource_type:snapshot

The same graph selection syntax covered in dbt run applies directly โ€” dbt build is a superset of what dbt run does, not a different selection model.


When Separate Commands Are Still the Right Choice

dbt buildโ€™s all-in-one nature isnโ€™t always what you want. Snapshots, in particular, are usually excluded from CI/PR validation runs entirely, as covered in dbt snapshot, since running them against an ephemeral CI database either fails outright or pollutes history with test data.

Terminal window
# A common CI pattern: build everything except snapshots
dbt build --exclude resource_type:snapshot
# Production job: snapshots run separately on their own schedule, before the main build
dbt snapshot
dbt build --exclude resource_type:snapshot

Separate commands are also more useful during fast local iteration, where you might genuinely want to build a model without immediately re-running its (possibly slow) downstream tests every single time you save a file.


Failure Modes: โ€”fail-fast

By default, dbt build continues processing independent parts of the DAG even after a failure elsewhere, skipping only what actually depends on the failed node. --fail-fast changes this to stop the entire run immediately at the first failure.

Terminal window
dbt build --fail-fast

This trades thoroughness (seeing every failure in one run) for speed (stopping immediately rather than continuing to process unrelated, unaffected parts of the DAG) โ€” useful in a fast local feedback loop, less useful in a scheduled production job where you generally want the full picture of what broke.


Reading a Mixed-Resource-Type Run

A dbt build run against a project with seeds, models, snapshots, and tests shows all of them interleaved in dependency order, not grouped by type:

1 of 24 START seed country_region_mapping ................ [RUN]
1 of 24 OK loaded seed country_region_mapping ............ [INSERT 12 in 0.3s]
2 of 24 START snapshot customers_snapshot ................ [RUN]
2 of 24 OK snapshotted customers_snapshot ................. [INSERT 3 in 0.5s]
3 of 24 START sql table model staging.stg_orders ......... [RUN]
3 of 24 OK created sql table model staging.stg_orders .... [SELECT 48213 in 1.1s]
4 of 24 START test unique_stg_orders_order_id ............ [RUN]
4 of 24 PASS unique_stg_orders_order_id ................... [PASS in 0.4s]

This ordering reflects the actual DAG โ€” the seed and snapshot happened to have no dependencies blocking them, so they ran first, followed by the model that depends on both, immediately followed by its test, before anything downstream of it begins.


dbt build in a Production Orchestration Job

A realistic production job sequence, combining whatโ€™s covered across dbt Sources, dbt Source Freshness, and this command:

Terminal window
dbt deps
dbt source freshness
dbt snapshot
dbt build --exclude resource_type:snapshot
dbt docs generate

Freshness first (fail fast if sources are stale), snapshots next (capture history before anything changes further), then the interleaved build-and-test pass, then documentation regeneration as the final step.


Common Mistakes

Assuming dbt build and dbt run + dbt test are equivalent. They produce similar end states on a fully passing run, but differ meaningfully on partial failure โ€” only dbt build prevents downstream models from building on top of known-bad upstream data within the same invocation.

Including snapshots in every CI run without exclusion. This is one of the most common dbt build misconfigurations โ€” always exclude snapshots from ephemeral/CI environments unless you specifically intend to test snapshot logic itself.

Using --fail-fast in scheduled production jobs. This can leave you with an incomplete picture of what actually broke, since the run stops at the very first failure instead of surfacing every issue in one pass.

Summary

Aspectdbt build
Resource types coveredSeeds, models, snapshots, tests โ€” all in one pass
Failure containmentSkips models downstream of a failed test automatically
Selection syntaxIdentical graph-based syntax to dbt run
Typical exclusionSnapshots, in CI/ephemeral environments

dbt build is the closer-to-correct default for most production pipelines โ€” the separate run/test/seed commands remain useful for fast, scoped local iteration, but for anything shipping to production, the interleaved, failure-aware execution of dbt build is worth the switch.