{"record":{"id":"8b84784e7f70eeae","repo":"prestodb/presto","slug":"not-supported-8b8478","errorCode":"NOT_SUPPORTED","errorMessage":"Multiple tables matched: ","messagePattern":"Multiple tables matched: ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-clickhouse/src/main/java/com/facebook/presto/plugin/clickhouse/ClickHouseClient.java","lineNumber":318,"sourceCode":"    {\n        try (Connection connection = connectionFactory.openConnection(identity)) {\n            String remoteSchema = toRemoteSchemaName(session, identity, connection, schemaTableName.getSchemaName());\n            String remoteTable = toRemoteTableName(session, identity, connection, remoteSchema, schemaTableName.getTableName());\n            try (ResultSet resultSet = getTables(connection, Optional.of(remoteSchema), Optional.of(remoteTable))) {\n                List<ClickHouseTableHandle> tableHandles = new ArrayList<>();\n                while (resultSet.next()) {\n                    tableHandles.add(new ClickHouseTableHandle(\n                            connectorId,\n                            schemaTableName,\n                            null, //\"datasets\",\n                            resultSet.getString(\"TABLE_SCHEM\"),\n                            resultSet.getString(\"TABLE_NAME\")));\n                }\n                if (tableHandles.isEmpty()) {\n                    return null;\n                }\n                if (tableHandles.size() > 1) {\n                    throw new PrestoException(NOT_SUPPORTED, \"Multiple tables matched: \" + schemaTableName);\n                }\n                return getOnlyElement(tableHandles);\n            }\n        }\n        catch (SQLException e) {\n            throw new PrestoException(JDBC_ERROR, e);\n        }\n    }\n\n    protected ResultSet getTables(Connection connection, Optional<String> schemaName, Optional<String> tableName)\n            throws SQLException\n    {\n        DatabaseMetaData metadata = connection.getMetaData();\n        Optional<String> escape = Optional.ofNullable(metadata.getSearchStringEscape());\n        return metadata.getTables(\n                connection.getCatalog(),\n                escapeNamePattern(schemaName, escape).orElse(null),\n                escapeNamePattern(tableName, escape).orElse(null),","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-clickhouse/src/main/java/com/facebook/presto/plugin/clickhouse/ClickHouseClient.java#L300-L336","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Rename one of the duplicate tables so names differ beyond case.","Drop the obsolete duplicate table from the ClickHouse schema.","Query with the exact correct-case table name or enable/adjust case-insensitive-name-mapping configuration consistently.","List tables in the schema (SHOW TABLES) and identify the conflicting pair named in the message.","Align table naming conventions to avoid case-only collisions."],"exampleFix":"-- before: both 'events' and 'Events' exist in schema 'analytics'\nSELECT * FROM analytics.events;\n-- after: remove the duplicate\nDROP TABLE analytics.\"Events\";\nSELECT * FROM analytics.events;","handlingStrategy":"validation","validationCode":"-- detect case-only duplicates before querying\nSHOW TABLES FROM clickhouse.analytics;\n-- ensure exactly one table resolves to the name you use","typeGuard":null,"tryCatchPattern":"try {\n    return connector.getTableHandle(session, tableName);\n} catch (PrestoException e) {\n    if (e.getErrorCode().getCode() == StandardErrorCode.NOT_SUPPORTED.toErrorCode().getCode()\n            && e.getMessage().startsWith(\"Multiple tables matched\")) {\n        throw new IllegalStateException(\"ambiguous table name: \" + tableName + \"; dedupe in ClickHouse first\", e);\n    }\n    throw e;\n}","preventionTips":["Enforce naming conventions that forbid case-only distinctions.","Periodically audit ClickHouse databases for duplicate tables.","Keep case-insensitive-name-mapping consistent across all nodes.","Drop stale tables created by migrations."],"tags":["clickhouse","jdbc","connector","ambiguous-name"],"backgroundTag":"ambiguous-table-name","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}