dbt run vs build

dbt run vs dbt build

When to Use Each Command

10 minutes to read
Get free consultation

 

If you’re building analytics pipelines with dbt, choosing between dbt run and dbt build matters more than it sounds. Pick the wrong command and you risk longer feedback loops, higher warehouse spend, and missed tests in production. Pick the right one and you get fast developer iteration, tight CI checks, and consistent data quality.

In this guide, we clarify dbt run vs dbt build with practical examples, a decision tree, and our CI/CD playbook. Our stance from dozens of dbt implementations: use run for local development and targeted debugging; use build for CI and production to orchestrate models, seeds, snapshots, and tests in DAG order.

We’ll also show how to combine state:modified, –defer, and the –empty flag for lean, cost-effective pipelines.

Summary - dbt run vs dbt build

Quick answer

Authoritative references:

At-a-glance differences

What dbt run does

Execution flow and materializations

dbt run compiles and executes only the selected SQL models against your target. It respects each model’s materialization (view, table, incremental). DAG order still applies for the selected set, but dbt doesn’t run tests or touch seeds/snapshots.

More details in the “dbt run command” docs: https://docs.getdbt.com/reference/commands/run

Common flags (–full-refresh, –select, –empty)

When to use dbt run (local dev, targeted)

Example commands and expected output

 

Local development:

dbt run –select my_model+

 

Rebuild only incremental-tagged models:

dbt run –full-refresh –select tag:incremental

 

Schema-only dry run (CI sanity check):

dbt run –select my_domain.* –empty –fail-fast

 

Expected: Models materialize in selection order respecting dependencies; no tests run.

What dbt build does

Models, seeds, snapshots, tests in DAG order

dbt build orchestrates all resource types for your selection:

See “dbt build command”: https://docs.getdbt.com/reference/commands/build

Test behavior – unit tests pre-materialization, data tests post

This ordering ensures you catch logic errors early and data quality issues before downstream models build.

Skipping downstream on test failures and severity control

When a critical test fails, dbt build will skip downstream nodes rather than continue building on top of broken data. You can also mark certain tests with severity: warn so build proceeds while still surfacing issues.

Example log snippet:

13:22:08 | 1 of 4 START model stg_orders ........................ OK
13:22:10 | 2 of 4 START test not_null_orders_id .................. 
13:22:12 | 2 of 4 FAIL not_null_orders_id  (1 failure)
13:22:12 | Skipping downstream 2 nodes due to test failure
13:22:12 | Finished running 1 model, 1 test in 4.01s

When to use dbt build (production, CI)

Example commands and expected output

 

CI Slim build (fast feedback):

dbt build –select “state:modified+” –defer –state path/to/prod_artifacts –fail-fast –empty

 

Nightly production:

dbt build –selector nightly_domain

 

Expected: Seeds/snapshots/models/tests run in graph order. Failing critical tests stop unsafe downstream work.

Choosing the right command by scenario

Local development and debugging

Pick run for speed and focus. A few patterns we rely on:

Pull request checks (Slim CI state:modified + –defer + –empty)

Goal: Validate only what changed and its immediate graph neighborhood, while deferring to production artifacts for everything else.

Command:

dbt build –select “state:modified+” –defer –state path/to/prod_artifacts –fail-fast –empty

 

Persist manifest.json and run_results.json from production after each deploy so CI has accurate state.

Nightly production jobs (full DAG vs partial)

Incremental models and full-refresh workflows

Selection syntax patterns that matter

See “dbt selection syntax”: https://docs.getdbt.com/reference/node-selection/syntax

Graph operators (+, @) and practical recipes

Combine operators to express intent clearly:

State-aware selections (state:modified)

This is the backbone of Slim CI.

Excluding tests or resource types

CI/CD recommendations (Stellans playbook)

We standardize on build for CI and prod, with state-aware selections to keep runs fast and cheap.

Minimal PR job (fast feedback)

Example GitHub Actions:

name: dbt PR checks
on: pull_request

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.11'
      - run: pip install dbt-core dbt-bigquery
      - name: dbt deps
        run: dbt deps
      - name: Slim CI
        run: dbt build --select "state:modified+" --defer --state artifacts/prod --fail-fast --empty

Pre-merge gating and data quality

Production job stages and rollbacks

If you orchestrate with Airflow, dbt Cloud operators make it straightforward: https://airflow.apache.org/docs/apache-airflow-providers-dbt-cloud/stable/operators.html

For more end-to-end process design and templates, see our dbt project structure conventions post: https://stellans.io/dbt-project-structure-conventions/

Common pitfalls and how to avoid them

Running dbt run without tests in prod

Symptom: Silent data quality regressions. Fix: Use dbt build in prod to run unit/data tests in order and skip unsafe downstream work.

Misusing full-refresh on large tables

Symptom: Cost spikes and long jobs. Fix: Reserve –full-refresh for schema/logic changes and schedule off-hours; prefer incremental merges.

Over-selecting resources and long runtimes

Symptom: Slow CI and high spend. Fix: Use state:modified+, tags, and domain-specific selectors. In CI, combine –defer and –empty for zero-row validation.

Decision tree - Should I use run or build?

Are you in CI or Production?
  ├─ Yes → Do you need tests, seeds, or snapshots orchestrated?
  │        ├─ Yes → Use dbt build (with state:modified, --defer in CI)
  │        └─ No  → Still prefer dbt build for safety; scope your selection
  └─ No (Local Dev) → Need fast, targeted debug without tests?
           ├─ Yes → Use dbt run (e.g., dbt run --select my_model+)
           └─ No  → Use dbt build to validate end-to-end when finalizing work

Example scenarios and outputs

BigQuery nuance with --empty and wildcard tables

When using –empty, dbt limits ref() and source() to zero rows. This is ideal for CI, but be careful if your SQL relies on wildcard tables or _TABLE_SUFFIX logic. Ensure your selection and test queries don’t inadvertently trigger wide wildcard scans. A refresher on BigQuery wildcard behavior: https://cloud.google.com/bigquery/docs/querying-wildcard-tables

Other commands you’ll combine with run/build

See “Run your dbt projects” overview: https://docs.getdbt.com/docs/running-a-dbt-project/run-your-dbt-projects

Best-practice patterns we recommend

Community perspective: “production command patterns” discussion: https://discourse.getdbt.com/t/the-exact-dbt-commands-we-run-in-production/6692

FAQ (PAA-aligned)

About Stellans

We design dbt workflows that balance speed and safety: fast developer loops, fast CI feedback, and safe production runs. Our implementations standardize on Slim CI, resilient domain selectors, and clear test severity, which reduces spend while improving reliability.

Conclusion

Use dbt run to move fast in development; use dbt build to ship safely in CI and production. Add Slim CI patterns such as state:modified, –defer, and –empty to cut PR feedback time and warehouse costs without sacrificing quality. The payoff: fewer failed runs, faster delivery, and trusted downstream reporting.

Want help designing reliable dbt pipelines? We’ll work with you to streamline CI/CD, reduce spend, and ship trusted datasets. Explore our dbt development services: https://stellans.io/services/ or Contact Stellans to discuss your roadmap: https://stellans.io/services/

External references cited above:

Article By:

https://stellans.io/wp-content/uploads/2025/07/AntotStellans1-4-1.webp
Anton Malyshev

Co-founder and COO at Stellans

Related Posts

    Get a Free Data Audit

    * You can attach up to 3 files, each up to 3MB, in doc, docx, pdf, ppt, or pptx format.