Configuring deferral in dbt State
By default, dbt State defers to your production environment. You only need to configure this if you want to change that behavior:
-
dbt platform: To defer to an environment other than the default (for example, staging), add
defer-env-idto thedbt-cloudblock indbt_project.yml. Refer to Configure the dbt platform CLI for more information.dbt_project.ymldbt-cloud:
project-id: <your-project-id>
defer-env-id: <your-environment-id>notedefer-env-idis manifest-based. If you set it, dbt State-poweredstate:*selectors are disabled. Refer to that section's requirements for more information. -
Self-managed deployments: If you can't access a production or deployment manifest, you can set
defer_to_targetinprofiles.ymlfor best-effort auto-deferral. Note that this approach has known limitations; refer to Caveats to dbt State without a manifest.profiles.ymlmy_project:
outputs:
uat:
type: snowflake
# ... connection settings
defer_to_target: stagingIn self-managed deployments, you can use dbt State-powered
state:*selectors, which compare each node against its own last execution rather than a single job'smanifest.json. To use this feature, connect your project to the dbt platform.
You can also pass --state or --defer-state to explicitly point dbt State to a specific manifest.json.
If you've overridden generate_*_name() macros with runtime values (such as environment variables, file paths, or dates), provide a manifest.json file so dbt State can locate objects correctly. Without one, it infers object locations from your macros and profile target, which may be incorrect in these cases. Refer to Caveats to dbt State without a manifest.
dbt State-powered state:* selectors Beta
When dbt State is enabled, state:* selectors can use dbt State as their comparison source instead of a single manifest.json from the most recent job run. Each node (models, snapshots, seeds, and tests) is compared against its own last execution in the defer_to_target environment (default: prod), so a node is only selected as modified if its own logic changed, no matter which job last ran it.
This feature is for self-managed deployments, meaning you orchestrate dbt runs yourself (for example, with Airflow or GitHub Actions) rather than with dbt platform jobs. You still authenticate to the dbt platform for dbt State using project-id.
Prerequisites
- dbt State is enabled for your project.
project-idis set in thedbt-cloudblock indbt_project.yml:
dbt-cloud:
project-id: <your-project-id>
When orchestrating with the dbt platform, each job produces a manifest.json, so dbt State uses that for state:* comparisons instead of per-node execution history.
Specify your project or org
If you have multiple projects or orgs that use dbt State, configure the dbt-cloud block in dbt_project.yml so dbt State knows which one to use:
-
For dbt platform users with multiple projects: Add
project-idto identify which project dbt State should use.dbt_project.ymldbt-cloud:
project-id: <your-project-id> -
For self-managed deployments with multiple dbt State orgs: Add
state-org-idto identify which org dbt State should use.dbt_project.ymldbt-cloud:
state-org-id: <your-org-id>
Related docs
Was this page helpful?
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.