Dbt run vs dbt build: Key Differences and Usage Guide
dbt run executes only model nodes in your dbt project, while dbt build runs models plus tests, snapshots, and seeds in one command. Use dbt build for a full project build including validation, and dbt run when you want to just compile and run models.Quick Comparison
This table summarizes the main differences between dbt run and dbt build.
| Feature | dbt run | dbt build |
|---|---|---|
| Purpose | Runs only model nodes | Runs models, tests, snapshots, and seeds |
| Includes Tests | No | Yes, runs tests after models |
| Includes Snapshots | No | Yes, runs snapshots |
| Includes Seeds | No | Yes, loads seeds |
| Typical Use Case | Quick model execution | Full project build and validation |
| Command Introduced | Original dbt command | Introduced in dbt v1.0 |
Key Differences
dbt run is designed to compile and execute only the model SQL files in your project. It builds the tables or views defined by your models but does not run any tests, snapshots, or seed loading. This makes it faster when you only want to update your models.
On the other hand, dbt build is a newer command introduced in dbt version 1.0 that combines multiple steps into one. It runs models, then runs tests to validate data quality, loads seed files, and executes snapshots if defined. This command is useful for a full project refresh and validation in one go.
Using dbt build helps ensure your data pipeline is not only built but also verified for correctness immediately after. dbt run is more focused and faster when you only need to update models without additional checks.
Code Comparison
Here is how you run models using dbt run:
dbt run
dbt build Equivalent
Here is how you run the full build including models, tests, seeds, and snapshots using dbt build:
dbt build
When to Use Which
Choose dbt run when: You want to quickly build or rebuild only your models without running tests, snapshots, or seeds. This is useful during development or when you know your data quality is already verified.
Choose dbt build when: You want a full project execution that includes building models, running tests to check data quality, loading seeds, and running snapshots. This is ideal for production runs or full refreshes to ensure data correctness.
Key Takeaways
dbt run runs only models, making it faster for model-only builds.dbt build runs models plus tests, snapshots, and seeds for full validation.dbt run for quick iterative development.dbt build for production or full pipeline execution.dbt build was introduced in dbt v1.0 to simplify multi-step workflows.