prestodb/presto · error · PrestoException

NOT_SUPPORTED

NOT_SUPPORTED

Error message

Multiple tables matched: 

What it means

PrestoException (NOT_SUPPORTED) thrown by ClickHouseClient.getTableHandle when JDBC database metadata lookup returns more than one table matching the requested schema/table name after case-insensitive/mapping resolution. The connector requires an unambiguous mapping and refuses to guess which physical table to use.

Source

Thrown at presto-clickhouse/src/main/java/com/facebook/presto/plugin/clickhouse/ClickHouseClient.java:318

    {
        try (Connection connection = connectionFactory.openConnection(identity)) {
            String remoteSchema = toRemoteSchemaName(session, identity, connection, schemaTableName.getSchemaName());
            String remoteTable = toRemoteTableName(session, identity, connection, remoteSchema, schemaTableName.getTableName());
            try (ResultSet resultSet = getTables(connection, Optional.of(remoteSchema), Optional.of(remoteTable))) {
                List<ClickHouseTableHandle> tableHandles = new ArrayList<>();
                while (resultSet.next()) {
                    tableHandles.add(new ClickHouseTableHandle(
                            connectorId,
                            schemaTableName,
                            null, //"datasets",
                            resultSet.getString("TABLE_SCHEM"),
                            resultSet.getString("TABLE_NAME")));
                }
                if (tableHandles.isEmpty()) {
                    return null;
                }
                if (tableHandles.size() > 1) {
                    throw new PrestoException(NOT_SUPPORTED, "Multiple tables matched: " + schemaTableName);
                }
                return getOnlyElement(tableHandles);
            }
        }
        catch (SQLException e) {
            throw new PrestoException(JDBC_ERROR, e);
        }
    }

    protected ResultSet getTables(Connection connection, Optional<String> schemaName, Optional<String> tableName)
            throws SQLException
    {
        DatabaseMetaData metadata = connection.getMetaData();
        Optional<String> escape = Optional.ofNullable(metadata.getSearchStringEscape());
        return metadata.getTables(
                connection.getCatalog(),
                escapeNamePattern(schemaName, escape).orElse(null),
                escapeNamePattern(tableName, escape).orElse(null),

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Rename one of the duplicate tables so names differ beyond case.
  2. Drop the obsolete duplicate table from the ClickHouse schema.
  3. Query with the exact correct-case table name or enable/adjust case-insensitive-name-mapping configuration consistently.
  4. List tables in the schema (SHOW TABLES) and identify the conflicting pair named in the message.
  5. Align table naming conventions to avoid case-only collisions.

Example fix

-- before: both 'events' and 'Events' exist in schema 'analytics'
SELECT * FROM analytics.events;
-- after: remove the duplicate
DROP TABLE analytics."Events";
SELECT * FROM analytics.events;
Defensive patterns

Strategy: validation

Validate before calling

-- detect case-only duplicates before querying
SHOW TABLES FROM clickhouse.analytics;
-- ensure exactly one table resolves to the name you use

Try / catch

try {
    return connector.getTableHandle(session, tableName);
} catch (PrestoException e) {
    if (e.getErrorCode().getCode() == StandardErrorCode.NOT_SUPPORTED.toErrorCode().getCode()
            && e.getMessage().startsWith("Multiple tables matched")) {
        throw new IllegalStateException("ambiguous table name: " + tableName + "; dedupe in ClickHouse first", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Querying a ClickHouse table whose name resolves to multiple entries in the target schema — typically because caseSensitiveNameMatching maps several tables to the same requested name, or the schema holds tables differing only in case.

Common situations: ClickHouse database contains both 'MyTable' and 'mytable' with case-insensitive matching configured; duplicate tables created by migrations; a view and table with the same resolved name.

Understand the failure class

Background: Presto NOT_SUPPORTED error: what "not supported" means and how to fix it — this error's family across 3 libraries.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/8b84784e7f70eeae. Report an issue: GitHub.