dbt build constructs models, seeds, and snapshots, then runs tests against the result in dependency order. Compared to running dbt run, dbt test, and dbt snapshot separately, it is harder to break the pipeline and easier to wire into CI.
This article assumes stable features from the official dbt documentation and walks through the comparisons most often asked on the Analytics Engineer exam (run/test/snapshot vs. build, selectors, state/defer) from a practitioner's perspective.
dbt build constructs the selected resources (models, seeds, snapshots) along the DAG and then runs tests (generic and singular) once they are built. Tests whose dependencies are not satisfied are skipped automatically, and tests attached to failed upstream nodes do not run either.
The key benefits are ordering and atomicity. A single command runs build → validate end-to-end, preventing the ordering mistakes and missed steps you get from individual commands. Making dbt build the default CI entry point keeps operations stable.
| Command | Main target / role | What it does | Role inside dbt build |
|---|---|---|---|
| dbt run | models (materialization) | Runs model SQL to update tables, views, and incremental models | Runs inside build (before tests) |
| dbt test | generic/singular tests | Validates data quality with unique, not_null, and function-based tests | Runs together at the end of build |
| dbt snapshot | snapshots | Updates snapshot tables used for SCDs | Runs inside build (before tests) |
| dbt seed | seeds (CSV loads) | Loads CSV files into the target database | Runs inside build (before tests) |
| dbt build | All of the above combined | Builds in DAG order → tests against the result | The focus of this article. A good CI default |
Conceptual flow of dbt build
Minimal example
dbt build
# profiles.yml と dbt_project.yml が設定済みであれば、この1行で
# models/seeds/snapshots を構築し、最後に tests を実行します。dbt build resolves the DAG of selected nodes and builds models, seeds, and snapshots first. Tests always run after that, and only when their parent node (target table/view/snapshot/seed) succeeded. Ephemeral models are not materialized; they are inlined into the parent query.
Incremental models update incrementally by default, or rebuild from scratch when --full-refresh is set. Tests run against the post-update state, so quality checks always evaluate the latest build output.
Order-aware baseline (no extra flags)
dbt build
# DAG に基づいて seeds/models/snapshots → tests の順で動くdbt build supports flexible scoping with --select and --exclude. You can target by tag, file path, model name, or resource type (model:, snapshot:, seed:, test:), and state selectors like state:modified are also available. Append + for descendants, prefix + for ancestors.
In larger repos, combining tags, paths, and resource types to minimize scope is the most effective way to cut CI runtimes.
Common selector patterns
# 重要タグのモデルとその子孫だけを構築し、最後に tests
dbt build --select tag:critical+
# スナップショットだけを更新し、関連 tests のみ実行
dbt build --select snapshot:
# マート配下と依存元(祖先)を含めて構築
dbt build --select +path:models/marts/
# 変更点とその下流のみ(state ディレクトリの指定は別途)
dbt build --select state:modified+ --state target/dbt build runs independent nodes in parallel based on the configured thread count. When a node fails, its downstream nodes and the tests tied to them are skipped. With --fail-fast, the entire run stops at the first failure.
For DAGs with many branches, tune --threads to compress total runtime, and use --fail-fast for critical validation paths so failures surface as early as possible.
Parallelism and early failure
# 8 並列で実行し、最初の失敗で停止
dbt build --threads 8 --fail-fastThe standard incremental-build pattern is to point --state at production artifacts (such as manifest.json) and select only the changed nodes and their downstream with --select state:modified+. Adding --defer lets unselected upstream refs fall back to production-built objects, keeping CI work to a minimum.
This combination dramatically cuts per-PR validation time. Have the production job emit its artifacts each run, and wire the CI pipeline to read them.
A typical CI command
# プロダクションのアーティファクトを参照し、変更点とその下流のみを検証
# artifacts/ に本番の manifest.json 等がある前提
dbt build --select state:modified+ --state artifacts/ --deferdbt build is powerful, but mixing in full refreshes of incremental models or large batches of snapshots without thought inflates both runtime and cost. Lean on diffs and tests in CI, and separate schedules and workloads in production.
For data quality, use severity:error on critical tests and severity:warn on supporting ones, and enable store_failures to collect failing rows. That makes the improvement cycle much smoother.
Schema test config example (collect failures)
version: 2
models:
- name: orders
columns:
- name: id
tests:
- unique:
severity: error
store_failures: true
- not_null:
severity: errorAnalytics Engineer
問題 1
As an Analytics Engineer, you need to speed up PR validation. You want to reference the production artifacts (manifest.json) and build/validate only the changed models and their downstream. Which command is the most appropriate?
正解: A
The canonical approach is state:modified+ to select changed nodes and their downstream, --state to reference the production artifacts, and --defer to route unselected upstream refs to the production-built objects. B splits run/test, which risks ordering mistakes and missed selections. C uses tag:modified, which is not what you want. D runs only snapshot, not build.
Does dbt build also run exposures and source freshness?
No. dbt build only targets models, seeds, snapshots, and tests. Exposures are metadata, and source freshness is run separately with dbt source freshness.
What is the difference between dbt build and running dbt run then dbt test separately?
build follows the DAG to construct resources and always runs tests against the result at the end. Running them separately is prone to ordering and selection mismatches, so dbt build is the safer choice in CI.
Jobs that include snapshots are getting heavy. How should I handle that?
Separate snapshots by tag or path so you can split scheduled batches from PR validation. For PRs, run only diffs using state:modified+ with --defer, and leave large snapshots to the production schedule.
Practice with certification-focused question sets
無料で問題を解いてみるNicheeLab Editorial Team
NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.
dbt Models: SQL-Defined Transformation Units (2026)
Model fundamentals — SELECT-based definitions, naming, refs,...
dbt Analytics Engineering Exam: Complete Guide (2026)
Pass the AE Certification — scope, weighting, sample questio...
dbt Cloud vs dbt Core: Feature & Cost Comparison (2026)
Honest comparison of dbt Cloud vs. dbt Core — IDE, scheduler...
dbt Project Structure: models/seeds/macros Layout (2026)
Recommended dbt project layout — models, seeds, macros, snap...
dbt_project.yml Explained: Every Config (2026)
Every dbt_project.yml setting that matters — paths, vars, ma...