Data quality checks: "relation ... does not exist" in CI
A data quality tool queried a table that does not exist yet. In CI this almost always means the quality checks ran before the transforms that build the tables, so the relation has not been created.
What this error means
dbt, Soda, Great Expectations, or a pytest query fails with "relation \"orders\" does not exist" or "Table not found", even though the model exists in the project.
psycopg2.errors.UndefinedTable: relation "analytics.orders" does not exist
LINE 1: select count(*) from analytics.ordersCommon causes
Transforms did not run before quality checks
The workflow ran the quality step before dbt run/dbt build or the extract that creates the table, so the relation is absent.
The check targets the wrong schema or database
The tool points at a schema the CI run did not populate, for example a production target instead of the CI target.
How to fix it
Build transforms before quality checks
- Run the models or extracts that create the tables.
- Then run the quality checks against them.
- Order steps so quality always follows data production.
- run: dbt build # create the relations
- run: soda scan -d wh -c configuration.yml checks/orders.ymlPoint checks at the CI schema
Ensure the tool config targets the same schema/database the CI transforms wrote to, not a production target.
How to prevent it
- Sequence data production before quality gates in the workflow.
- Target the CI schema explicitly in every tool config.
- Use
dbt buildso tests run right after their model materializes.