dbt "Compilation Error" in tests in CI
dbt failed at compile time, before running any test, because a model or test references something it cannot resolve: an undefined ref, a missing macro, or a column that does not exist in the manifest.
What this error means
A dbt test or dbt build step fails with "Compilation Error in test ..." naming an undefined ref, macro, or column, and no tests actually run.
Compilation Error in test not_null_orders_customer_id (models/marts/orders.yml)
Model 'model.shop.orders' depends on a node named 'stg_customers' which
was not foundCommon causes
An undefined ref or source
A test or model refs a node that does not exist in the project, or a source that is not declared, so compilation fails.
A missing macro or package
A test uses a macro from a package (for example dbt_utils) that was not installed with dbt deps in CI.
How to fix it
Install packages and validate the graph
- Run
dbt depsso package macros are available. - Run
dbt parseordbt compileto surface graph errors early. - Fix the undefined ref, source, or column the error names.
- run: dbt deps
- run: dbt compile # fail fast on compilation errors before testsCorrect the reference
Point the ref at a real model name, declare the missing source, or fix the column name in the test config.
How to prevent it
- Run
dbt depsbefore compile in CI. - Add
dbt compileas an early fail-fast step. - Keep refs, sources, and column names in sync with the models.