apache/seatunnel · error · ClickhouseConnectorException
TABLE_SCHEMA_GET_FAILED
TABLE_SCHEMA_GET_FAILED
Error message
Cannot get table schema from clickhouse
What it means
ClickhouseProxy.getClickhouseTableSchema issues a DESCRIBE-style query against system.columns and wraps any ClickHouseException into a ClickhouseConnectorException with CommonErrorCodeDeprecated.TABLE_SCHEMA_GET_FAILED. It means the connector could not read the column name/type pairs for the requested table.
Source
Thrown at seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/util/ClickhouseProxy.java:172
public Map<String, String> getClickhouseTableSchema(String table) {
ClickHouseRequest<?> request = getClickhouseConnection();
return getClickhouseTableSchema(request, table);
}
public Map<String, String> getClickhouseTableSchema(
ClickHouseRequest<?> request, String table) {
String sql = "desc " + table;
Map<String, String> schema = new LinkedHashMap<>();
try (ClickHouseResponse response = request.query(sql).executeAndWait()) {
response.records()
.forEach(
r -> {
if (!"MATERIALIZED".equals(r.getValue(2).asString())) {
schema.put(r.getValue(0).asString(), r.getValue(1).asString());
}
});
} catch (ClickHouseException e) {
throw new ClickhouseConnectorException(
CommonErrorCodeDeprecated.TABLE_SCHEMA_GET_FAILED,
"Cannot get table schema from clickhouse",
e);
}
return schema;
}
public List<ClickHouseColumn> getClickHouseColumns(String table) {
String sql = "SELECT * FROM " + table + " WHERE 1 = 0";
try (ClickHouseResponse response = this.clickhouseRequest.query(sql).executeAndWait()) {
return response.getColumns();
} catch (ClickHouseException e) {
throw new ClickhouseConnectorException(
CommonErrorCodeDeprecated.TABLE_SCHEMA_GET_FAILED,
"Cannot get table schema from clickhouse",
e);
}View on GitHub (pinned to cf67b549a7)
Solutions
- Confirm the table exists: SELECT name FROM system.tables WHERE database='<db>' AND name='<table>';
- Validate database and table names in the connector config (quote identifiers containing dots)
- Grant the ClickHouse user SELECT privilege on the table and system.columns
- Check network connectivity and credentials in the ClickHouse URL/options
- Retry if the failure was a transient ClickHouseException (server restart, timeout)
Example fix
// before Map<String,String> schema = proxy.getClickhouseTableSchema(request, "events"); // table in db 'prod', not default // after Map<String,String> schema = proxy.getClickhouseTableSchema(request, "prod.events"); // fully qualified name
Defensive patterns
Strategy: validation
Validate before calling
if (!proxy.tableExists(request, database, table)) {
throw new IllegalArgumentException(database + "." + table + " does not exist");
} Try / catch
try {
Map<String,String> schema = proxy.getClickhouseTableSchema(request, table);
} catch (ClickhouseConnectorException e) {
// inspect cause ClickHouseException for auth/connectivity; retry once on transient errors
throw new RuntimeException("Schema read failed: " + e.getMessage(), e);
} Prevention
- Use fully qualified database.table names
- Grant SELECT on the table and system.columns before running jobs
- Pre-check existence with tableExists before reading schema
- Monitor ClickHouse availability during job startup
When it happens
Trigger: Calling getClickhouseTableSchema (directly or via getClickhouseTable) when the table does not exist, the database name is wrong, or the query fails due to connection/auth/timeout errors surfaced as ClickHouseException.
Common situations: Typo in table name in config; user lacks SELECT privilege on the table; ClickHouse server unreachable or restarted mid-query; materialized views referenced without permissions.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Failed to read schema for table %s
- Failed getting table %s
- TABLE_NOT_EXISTED
- CLUSTER_LIST_GET_FAILED
- LIST_DATABASES_FAILED
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/244ca647a6db708c.
Report an issue: GitHub.