Optimize static analysis for development and deployment
dbt v2 is available for installation in:
- Local command line interface (CLI) tools
- VS Code and Cursor with the dbt extension
- dbt platform environments
Join the conversation in our Community Slack channel #dbt-fusion-engine.
Static analysis helps dbt v2 validate your SQL before it runs. This guide shows how to configure it so you get stronger checks while you develop, and faster, less blocking runs in deployment.
This guide explains why using strict in development and baseline (the default, lighter static analysis mode) in deployment is a valid and recommended pattern, and how to configure it in your dbt v2 project. For more information about modes and features, refer to About static analysis.
Why this pattern
- Development:
strictmode has the strongest SQL checks before you promote changes, including richer column-level features in the VS Code extension. - Deployment:
baselineskips remote warehouse schema downloads and surfaces findings as warnings, so jobs are less likely to block. That can save compile time (and warehouse cost) in deployment, especially in projects with many sources. Review deployment logs for warnings thatstrictwould have raised as errors in development.
strict can increase compile time because dbt v2 downloads schemas for all sources (including sources your models do not reference). Teams with thousands of sources have seen large differences between baseline and strict.
Set the mode with the CLI flag
Use the --static-analysis flag to set the mode for a single run.
Development:
dbt compile --static-analysis strict
Deployment:
dbt compile --static-analysis baseline
You can use the same flag with dbt run or dbt build. If you already have dbt v1 or the platform CLI installed alongside dbt v2, use dbtf as the unambiguous dbt v2 command.
You can also configure static_analysis per directory or model. Refer to Configuring static_analysis for examples.
Set the mode with an environment variable
You can also drive static_analysis from a custom environment variable in dbt_project.yml. This is useful when development and deployment share the same project config but set different environment values.
models:
my_project:
+static_analysis: "{{ env_var('DBT_ENV_STATIC_ANALYSIS', 'baseline') }}"
Then set the variable per environment:
- Development:
DBT_ENV_STATIC_ANALYSIS=strict - Deployment: leave unset (defaults to
baseline), or setDBT_ENV_STATIC_ANALYSIS=baseline
DBT_ENV_STATIC_ANALYSIS is a custom variable name you choose. It is separate from the built-in DBT_STATIC_ANALYSIS override used with the CLI flag.
For more information about env_var, refer to About env_var and Environment variables.
Related docs
Was this page helpful?
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.