{"id":2908,"library":"dagster-dbt","title":"Dagster dbt Integration","description":"dagster-dbt provides a robust integration for dbt within the Dagster ecosystem. It allows users to define dbt models, seeds, snapshots, and tests as first-class Dagster assets, enabling rich metadata, lineage tracking, and seamless orchestration alongside other data tools. The library is actively developed and typically releases new versions in sync with Dagster core, with the current version being 0.29.0, corresponding to Dagster 1.13.0.","status":"active","version":"0.29.0","language":"en","source_language":"en","source_url":"https://github.com/dagster-io/dagster/tree/master/python_modules/libraries/dagster-dbt","tags":["dbt","etl","orchestration","data assets","data transformation","data quality"],"install":[{"cmd":"pip install dagster-dbt dbt-core dbt-snowflake # or dbt-bigquery, dbt-redshift, etc.","lang":"bash","label":"Install dagster-dbt and dbt adapter"}],"dependencies":[{"reason":"Required for dbt CLI functionality and project parsing.","package":"dbt-core","optional":false},{"reason":"A dbt adapter (e.g., `dbt-snowflake`, `dbt-bigquery`) is necessary for dbt to connect to your data warehouse.","package":"dbt-<adapter>","optional":false}],"imports":[{"symbol":"DbtCliResource","correct":"from dagster_dbt import DbtCliResource"},{"symbol":"DbtProject","correct":"from dagster_dbt import DbtProject"},{"note":"The dbt_assets decorator is directly exposed at the top level of the `dagster_dbt` package for convenience.","wrong":"from dagster_dbt.asset_decorator import dbt_assets","symbol":"dbt_assets","correct":"from dagster_dbt import dbt_assets"},{"symbol":"DagsterDbtTranslator","correct":"from dagster_dbt import DagsterDbtTranslator"},{"note":"DbtCloudComponent was added in `dagster-dbt 0.28.20` but the current best practice for dbt Cloud integrations leverages `DbtCloudClientResource` and `load_dbt_cloud_asset_specs` from `dagster_dbt.cloud_v2` for more granular control and observability.","wrong":"from dagster_dbt import DbtCloudComponent","symbol":"DbtCloudClientResource","correct":"from dagster_dbt.cloud_v2.resources import DbtCloudClientResource"}],"quickstart":{"code":"from pathlib import Path\nfrom dagster import AssetExecutionContext, Definitions\nfrom dagster_dbt import DbtCliResource, DbtProject, dbt_assets\n\n# Assuming your dbt project is in a subdirectory named 'my_dbt_project'\ndbt_project_dir = Path(__file__).parent / \"my_dbt_project\"\n\n# Initialize DbtProject, which handles manifest compilation\n# For dev, prepare_if_dev() compiles the manifest if it's missing or outdated\ndbt_project = DbtProject(project_dir=dbt_project_dir)\ndbt_project.prepare_if_dev()\n\n# Define dbt assets using the @dbt_assets decorator\n# The manifest path is required to infer assets and their dependencies\n@dbt_assets(manifest=dbt_project.manifest_path)\ndef my_dbt_models(context: AssetExecutionContext, dbt: DbtCliResource):\n    # Execute dbt build command and stream events to Dagster\n    yield from dbt.cli([\"build\"], context=context).stream()\n\n# Combine assets and resources into a Dagster Definitions object\ndefs = Definitions(\n    assets=[my_dbt_models],\n    resources={\n        \"dbt\": DbtCliResource(project_dir=dbt_project),\n    },\n)","lang":"python","description":"This quickstart demonstrates how to define Dagster assets from an existing dbt project. It uses `DbtProject` to manage the dbt project and its manifest, and the `@dbt_assets` decorator along with `DbtCliResource` to execute dbt commands and stream events back to Dagster. Ensure you have a valid dbt project structure in the `my_dbt_project` directory relative to this Python file."},"warnings":[{"fix":"Always consult the official `dagster-dbt` documentation for the supported `dbt-core` versions for your specific `dagster-dbt` release. Pin both `dagster-dbt` and `dbt-core` to compatible versions in your `pyproject.toml` or `requirements.txt`.","message":"Version compatibility with `dbt-core` is crucial. `dagster-dbt` supports specific ranges of `dbt-core` versions (e.g., 1.7 through 1.11 for `dagster-dbt 0.29.0`). Incompatibilities can lead to module loading errors or unexpected behavior.","severity":"breaking","affected_versions":"<0.29.0 for some dbt-core 1.x versions, check docs for exact matrix"},{"fix":"Explicitly set `backfill_policy` in your `@dbt_assets` decorator if you rely on a specific backfill behavior for partitioned dbt models.","message":"When using `@dbt_assets` with a time window partition definition and no explicit backfill policy, the default policy changed from `BackfillPolicy.multi_run()` to `BackfillPolicy.single_run()` in a previous Dagster 1.12.0 release. This might change how backfills execute for partitioned dbt assets.","severity":"gotcha","affected_versions":"Dagster 1.12.0+"},{"fix":"Migrate to `dagster_dbt.cloud_v2` for new dbt Cloud integrations to leverage the latest features and best practices for observability and orchestration. Refer to the 'Dagster & dbt Cloud' documentation for detailed examples.","message":"The `dbt_cloud_resource` and `load_assets_from_dbt_cloud_job` APIs are considered superseded by `dagster_dbt.cloud_v2` resources (`DbtCloudClientResource`, `DbtCloudCredentials`, `DbtCloudWorkspace`) and `load_dbt_cloud_asset_specs` for improved observability and orchestration capabilities.","severity":"deprecated","affected_versions":"All versions, considered superseded in recent Dagster releases"},{"fix":"For production deployments, consider configuring state management strategies for `DbtProject` to explicitly manage manifest generation, for example, by preparing the manifest at build time. During development, `refresh_if_dev=False` can disable automatic refreshing, but this means you'll need to manually recompile dbt if the project changes significantly.","message":"State-backed components, including `DbtProject` (formerly `DbtProjectComponent`), automatically refresh their state during development (`dagster dev` or `dg CLI commands`). While convenient, if an external API (like a dbt manifest) is unavailable or malformed, it can cause the entire code location to fail loading.","severity":"gotcha","affected_versions":"Dagster 1.13.0+"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}