RelationNotFound: relation 'analytics.dim_customers' does not exist"
Fixes the dbt RelationNotFound error by rebuilding the missing model, correcting the target schema in the profile, or pointing at the right database. Use when dbt or a downstream query fails because a relation is missing. Not for compile-time dependency errors, which name the missing node instead.
TL;DR
Something queried analytics.dim_customers and the warehouse says it is not there. Either the model was never built in this target, it was built into a different schema, or it was dropped. Rebuild the model with dbt run --select dim_customers, verify the schema in your profile target, and confirm the relation exists before rerunning downstream work.
Error
RelationNotFound: relation 'analytics.dim_customers' does not existSteps
- Check whether the relation exists right now by querying your warehouse's information schema for
dim_customersin schemaanalytics. Expected: you learn whether it is truly missing or just in the wrong schema. - Compare the schema against your profile target: the
schema(anddatabase) in profiles.yml for the active target must match where you are looking. Expected: the target schema equalsanalytics, or you adjust your expectation. - Rebuild the model:
dbt run --select dim_customers. Expected: the run succeeds and the relation appears in the warehouse. - If a downstream model or a docs query triggered the error, rerun it now. Expected: the RelationNotFound error is gone.
- If the relation keeps disappearing, check for a
--full-refreshin a scheduled job or a drop step that removes it. Expected: you find the job responsible.
When to use
- A dbt run, test, or docs query fails with RelationNotFound.
- You switched targets (dev to prod) and relations seem missing.
When not to use
- dbt compile fails with a dependency error (the node is missing from the graph, not the warehouse).
- The relation exists but queries fail with permission errors (a grants problem).
Tool compatibility
- dbt Core 1.0 and later, all adapters. Information schema queries differ slightly per warehouse.
Variant phrasings
relation "analytics.dim_customers" does not exist
The Postgres-style quoting of the same error; the fix is identical.
RelationNotFound on a seed or snapshot
Seeds and snapshots are relations too; rebuild with dbt seed or dbt snapshot.
Why it happens
dbt renders relation names from the target's database and schema plus the model name. A mismatch between where dbt built the model and where the query looks, or a model that was never built in this environment, produces this error.
Edge cases
- Custom schemas via
generate_schema_namechange where models land; check the macro before assuming the default. - On Snowflake, case matters: unquoted identifiers fold to uppercase.
- Cloned or time-traveled databases can hide recently built relations from the session that built them.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_bdvVfPTOggwj0Km7kfuOjw
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.