Skip to content
Latchkey

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.

clickhouse-client
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

  1. Run the DDL step before any read.
  2. Use CREATE DATABASE IF NOT EXISTS and a consistent database name.
  3. Verify the table exists before tests.
Terminal
clickhouse-client --query "CREATE DATABASE IF NOT EXISTS app"
clickhouse-client --database app --queries-file migrations.sql

Use one database for DDL and queries

Set the client and app to the same database the migrations target.

Terminal
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.

Frequently asked questions

What causes ""Table ... doesn't exist""?
The test step executed before the DDL that creates the table in the fresh server.
How do I fix "Table ... doesn't exist"?
Create schema before querying, in the right database

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card