apache/seatunnel · error · ClickhouseConnectorException

TABLE_NOT_EXISTED

TABLE_NOT_EXISTED

Error message

Cannot get table from clickhouse, resultSet is empty

What it means

ClickhouseProxy.getClickhouseDistributedTable() queries ClickHouse (system.tables via localTableSQL) to fetch the local table's engine and DDL; if the query returns no rows, it wraps the result as SeaTunnelAPIErrorCode.TABLE_NOT_EXISTED with 'Cannot get table from clickhouse, resultSet is empty'. It means ClickHouse returned nothing for the requested local table metadata, effectively the table doesn't exist or isn't visible.

Source

Thrown at seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/util/ClickhouseProxy.java:119

                                .collect(Collectors.toList());

                String clusterName = infos.get(0);
                String localDatabase = infos.get(1);
                String localTable = infos.get(2).replace(")", "").trim();

                String localTableSQL =
                        String.format(
                                "select engine,create_table_query,sorting_key from system.tables where database = '%s' and name = '%s'",
                                localDatabase, localTable);
                String localTableDDL;
                String localTableEngine;
                String sortingKey;
                try (ClickHouseResponse localTableResponse =
                        clickhouseRequest.query(localTableSQL).executeAndWait()) {
                    List<ClickHouseRecord> localTableRecords =
                            localTableResponse.stream().collect(Collectors.toList());
                    if (localTableRecords.isEmpty()) {
                        throw new ClickhouseConnectorException(
                                SeaTunnelAPIErrorCode.TABLE_NOT_EXISTED,
                                "Cannot get table from clickhouse, resultSet is empty");
                    }
                    localTableEngine = localTableRecords.get(0).getValue(0).asString();
                    localTableDDL = localTableRecords.get(0).getValue(1).asString();
                    localTableDDL = localizationEngine(localTableEngine, localTableDDL);
                    sortingKey = localTableRecords.get(0).getValue(2).asString();
                }

                return new DistributedEngine(
                        clusterName,
                        localDatabase,
                        localTable,
                        localTableEngine,
                        localTableDDL,
                        sortingKey);
            }
            throw new ClickhouseConnectorException(

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Verify database/table names in config match ClickHouse exactly (case-sensitive) via `SHOW TABLES FROM <db>`.
  2. Check grants: the connector user needs SELECT on the target table and system.tables.
  3. Confirm the table exists on every shard reachable by the configured url/cluster clause.
  4. Run the metadata SQL manually (SELECT engine, create_table_query FROM system.tables WHERE database=... AND name=...) to see why it returns empty.

Example fix

// before
url = "jdbc:clickhouse://ch-host:8123"
database = "Default"   // wrong case
// after
url = "jdbc:clickhouse://ch-host:8123"
database = "default"
table = "events_local"
Defensive patterns

Strategy: validation

Validate before calling

// Run before job submission
SELECT engine, create_table_query FROM system.tables
WHERE database = 'default' AND name = 'events_local';
// empty result -> connector will throw TABLE_NOT_EXISTED

Try / catch

try {
  catalog.getTable(path);
} catch (ClickhouseConnectorException e) {
  if (e.getSeaTunnelErrorCode() == SeaTunnelAPIErrorCode.TABLE_NOT_EXISTED) {
    // verify names/grants, then re-create or reconfigure
  } else throw e;
}

Prevention

When it happens

Trigger: SELECT of engine/DDL for a local table where system.tables has no matching row — wrong database/table name, missing privileges, table dropped, or cluster-function query (clusterAllReplicas) returning no rows from unreachable shards.

Common situations: Typo'd database or table in source config; connecting with a user lacking SELECT on system.tables; pointing at a cluster where the local table exists only on other shards; case-sensitive name mismatch.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/1e6abe0497a5ebcb. Report an issue: GitHub.