Dagster-dbt Integration: Run dbt Models as Data Assets
Dagster-dbt is the integration library that brings dbt projects into Dagster's asset graph. Instead of running dbt as an opaque command in a single task, each dbt model, seed and snapshot appears as its own asset. That gives analytics engineers lineage, selective runs and freshness visibility across the whole data platform, not just inside dbt.
Many teams already rely on dbt for SQL transformations in their warehouse. Pairing it with Dagster lets those transformations sit alongside ingestion jobs, Python models and downstream dashboards in one connected view.
Why Combine Dagster and dbt
dbt excels at modelling data with SQL, testing it and documenting it. It does not aim to coordinate everything that happens before and after those models run. Dagster fills that gap by orchestrating the full flow, from loading raw data to refreshing a machine learning feature table.
- See dbt models and Python assets in a single lineage graph.
- Run only the models affected by an upstream change.
- Schedule dbt builds together with ingestion and reporting steps.
- Surface dbt test results alongside other data quality checks.
How the Integration Works
The integration reads the dbt manifest, a JSON file dbt generates that describes every model and its dependencies. Using that manifest, Dagster creates one asset per dbt node and wires them together exactly as dbt defines them. When a run starts, Dagster calls the dbt CLI with the appropriate selection.
from dagster import AssetExecutionContext
from dagster_dbt import DbtCliResource, dbt_assets
@dbt_assets(manifest=dbt_manifest_path)
def my_dbt_assets(context: AssetExecutionContext, dbt: DbtCliResource):
yield from dbt.cli(["build"], context=context).stream()
The DbtCliResource points to your dbt project and profile. Results stream back as events, so each model shows its own materialisation status in the UI.
Preparing the manifest
The manifest must be available when Dagster loads your definitions. During development it is commonly generated by parsing the project, while production deployments often build it as part of the container image. The integration provides helpers for this, and the official documentation describes the current recommended approach.
Connecting dbt to Upstream and Downstream Assets
The real power appears when dbt sources link to assets produced elsewhere. If an ingestion asset loads raw orders, a dbt source pointing at that table can be mapped to the same asset key. Dagster then knows that the dbt staging model depends on the ingestion step.
Downstream, Python assets can depend on dbt models directly. A forecasting model or an export job can wait for the relevant dbt marts, creating an end-to-end graph from raw data to final output.
| Layer | Typical tool | Represented in Dagster as |
|---|---|---|
| Ingestion | Python or an ingestion integration | Upstream assets |
| Staging and marts | dbt models | One asset per model |
| Data tests | dbt tests | Checks linked to assets |
| Consumption | Python, ML or exports | Downstream assets |
Scheduling and Selecting dbt Models
You can materialise all dbt assets on a schedule or select a subset using dbt-style selection. Teams frequently run critical marts more often while refreshing large historical models less frequently. Partitioned approaches suit incremental models that process data by date.
Declarative automation offers another option. Rather than fixed times, assets can be refreshed when upstream data changes, which reduces unnecessary warehouse work and keeps important tables current.
Practical Tips for Teams
A few habits make the integration smoother. Keep the dbt project inside the same repository as your Dagster code, or at least version them together. Use consistent naming so asset keys are predictable, and document sources clearly.
- Generate the manifest in CI to catch dbt compilation errors early.
- Start by loading the dbt project without changes, then add upstream mappings.
- Use asset groups to separate dbt layers in the UI.
- Review warehouse costs when increasing refresh frequency.
Setting Up a Project with dagster-dbt
Installation follows the same pattern as other Dagster libraries. Add the dagster-dbt package together with the dbt adapter for your warehouse, then point the integration at your dbt project directory. The integration also offers scaffolding helpers that generate a starter Dagster project around an existing dbt project.
- Install dagster, dagster-webserver and dagster-dbt in one environment.
- Install the dbt adapter that matches your warehouse.
- Confirm dbt can parse and compile the project on its own.
- Load the project in Dagster and review the generated asset graph.
Partitioned and Incremental dbt Models
Incremental dbt models process only new or changed data, which pairs well with Dagster partitions. Passing partition information into dbt variables lets each run handle a specific time window. This keeps runs efficient and allows targeted backfills when historical data needs correction.
Troubleshooting the Integration
Most problems trace back to the manifest or the dbt profile. If assets are missing, regenerate the manifest and confirm the path. If runs fail immediately, check that the profile and credentials are available in the environment where Dagster executes dbt.
Reading the streamed dbt logs in the Dagster UI usually reveals the cause. Because each model reports separately, it is easy to see which model failed and whether downstream assets were skipped as a result.
Keeping dbt and Dagster versions aligned
Upgrade dagster-dbt alongside the core dagster package so their versions stay compatible. Review dbt release notes too, because changes to the manifest format can affect how the integration reads your project.
Frequently Asked Questions
Does Dagster replace dbt?
No. dbt still handles SQL transformations and tests, while Dagster orchestrates when they run and connects them to the rest of your pipeline.
Which package provides the integration?
The integration is provided by the dagster-dbt Python package, installed alongside the core dagster package.
Can I run only part of my dbt project?
Yes. Dagster supports selecting specific dbt assets, so you can materialise a subset of models instead of the entire project.
Do dbt tests appear in Dagster?
dbt test results can be surfaced in Dagster, typically as checks associated with the relevant assets.
Conclusion
Dagster-dbt turns a dbt project into first-class assets inside a wider orchestration graph. Models gain lineage across tools, runs become selective and scheduling reflects how data actually flows. Start by loading your existing project, connect sources to upstream assets and gradually introduce automation to keep every important table fresh.



