ClickHouse "Table ... doesn't exist" (UNKNOWN_TABLE) in CI
ClickHouse returns "Table X doesn't exist" (error code 60, UNKNOWN_TABLE) when a query targets a table that is not present. A fresh CI server is empty, so the migration step did not run, ran against another database, or failed.
What this error means
A query fails with "Code: 60. DB::Exception: Table default.events doesn't exist. (UNKNOWN_TABLE)" against a server started for the job.
Code: 60. DB::Exception: Table default.events doesn't exist. (UNKNOWN_TABLE)Common causes
Migrations ran after the query, or not at all
The test step executed before the DDL that creates the table in the fresh server.
The query and DDL used different databases
Creating the table in one database while querying default leaves the expected table missing.
How to fix it
Create schema before querying, in the right database
- Run the DDL step before any read.
- Use
CREATE DATABASE IF NOT EXISTSand a consistent database name. - Verify the table exists before tests.
clickhouse-client --query "CREATE DATABASE IF NOT EXISTS app"
clickhouse-client --database app --queries-file migrations.sqlUse one database for DDL and queries
Set the client and app to the same database the migrations target.
clickhouse-client --database app --query "SELECT count() FROM events"How to prevent it
- Order DDL before read steps.
- Pick one database name for migrations and queries.
- Assert tables exist after migrating.