dbt error: Compilation Error in model after upgrading dbt-core version
How to fix dbt's "Compilation Error in model" after upgrading dbt-core: aligning adapter and package versions with the new core, and updating code for breaking changes. Use when dbt compile or dbt run fails on compilation right after a dbt-core upgrade. Not for SQL errors at run time or warehouse permission problems.
TL;DR
The new dbt-core changed or removed something the project relied on: a macro, a config, or an adapter interface. Align every adapter and package version with the new core (dbt deps after updating packages.yml), read the compilation error for the exact macro or config it names, and update the model code. Compile before running: dbt compile is the fast feedback loop.
The query
dbt error: Compilation Error in model after upgrading dbt-core versionUse this when
- dbt compile fails with "Compilation Error in model" after upgrading dbt-core
- Models that compiled yesterday break on the new version
- Adapter or package version mismatch after upgrade
- An agent upgraded dbt-core and the project will not build
Not for
- SQL that fails at run time against the warehouse (a SQL problem, not compilation)
- Warehouse permission or connection errors (check the profile)
- Compilation errors unrelated to any upgrade (read the error the same way, minus the version angle)
Steps
1. Check the version set
dbt --versionExpected output: the installed dbt-core version and every adapter version. An adapter built for the old core is the most common break: adapters must track core.
2. Align adapters and packages
Update packages.yml and the adapter pins to versions supporting the new core, then:
dbt depsExpected output: dependencies install with no version conflicts. If deps resolves conflicts by picking something odd, pin explicitly rather than accepting the solver's guess.
3. Read the compilation error literally
dbt compile --select [failing model]Expected output: the error naming the macro, config, or syntax it chokes on, with a file and line. dbt-core upgrades usually break a small set of things (renamed macros, removed configs, stricter jinja): the error tells you which one.
4. Update the model code for the breaking change
Apply the documented migration for that breaking change: rename the macro, move the config, or rewrite the jinja. Change one model first and recompile it before batch-fixing the rest.
Expected output: dbt compile succeeds on the fixed model. Then roll the same fix across every model with the same pattern.
5. Compile the whole project, then run a slice
dbt compile
dbt run --select [one small model]Expected output: full-project compilation clean, and the slice runs green against the warehouse. Only then run the full project.
Tool compatibility
dbt-core 1.6 through 1.9 with matching adapters (dbt-postgres, dbt-snowflake, dbt-bigquery, etc.). Adapter-core alignment rules are the same across these.
Variant phrasings
dbt Compilation Error in model after upgrading dbt-core
Steps 1 through 3: version set, align, read the error.
dbt deps version conflict after core upgrade
Step 2: pin adapters explicitly to core-compatible versions instead of letting the solver guess.
dbt macro not found after upgrade
Steps 3 and 4: the macro was renamed or removed; the upgrade guide names the replacement.
Why it happens
dbt-core, adapters, and packages form a versioned triple: adapters implement interfaces that core versions change. Upgrading core alone leaves adapters calling an interface that no longer exists, and compilation is where the mismatch surfaces because macros and configs resolve at compile time. The fix is version alignment, not code heroics.
Edge cases
- Upgrading core and adapters in one commit makes failures hard to attribute: upgrade core first with old adapters pinned where compatible, or do it in two commits with a green build between.
- Some packages lag core by weeks: check the package's supported-core range before upgrading, or hold the core upgrade.
- dbt compile passing does not mean dbt run passes: compilation only proves the jinja and configs resolve, not that the SQL runs.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst61iJ-V5bugn8U50PffV3A