{"record":{"id":"b0912906800f684d","repo":"prestodb/presto","slug":"unexpected-tablename-expected-s-but-found-s","errorCode":null,"errorMessage":"Unexpected tableName, expected: %s, but found: %s","messagePattern":"Unexpected tableName, expected: (.+?), but found: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/glue/converter/GlueToPrestoConverter.java","lineNumber":165,"sourceCode":"        private final String tableName;\n\n        public GluePartitionConverter(String databaseName, String tableName)\n        {\n            this.databaseName = requireNonNull(databaseName, \"databaseName is null\");\n            this.tableName = requireNonNull(tableName, \"tableName is null\");\n        }\n\n        @Override\n        public Partition apply(software.amazon.awssdk.services.glue.model.Partition gluePartition)\n        {\n            requireNonNull(gluePartition.storageDescriptor(), \"Partition StorageDescriptor is null\");\n            StorageDescriptor sd = gluePartition.storageDescriptor();\n\n            if (!databaseName.equals(gluePartition.databaseName())) {\n                throw new IllegalArgumentException(format(\"Unexpected databaseName, expected: %s, but found: %s\", databaseName, gluePartition.databaseName()));\n            }\n            if (!tableName.equals(gluePartition.tableName())) {\n                throw new IllegalArgumentException(format(\"Unexpected tableName, expected: %s, but found: %s\", tableName, gluePartition.tableName()));\n            }\n\n            Partition.Builder partitionBuilder = Partition.builder()\n                    .setCatalogName(Optional.empty())\n                    .setDatabaseName(databaseName)\n                    .setTableName(tableName)\n                    .setValues(gluePartition.values()) // No memoization benefit\n                    .setColumns(columnsConverter.apply(sd.columns()))\n                    .setParameters(parametersConverter.apply(gluePartition.parameters()));\n\n            storageConverter.setConvertedStorage(sd, partitionBuilder.getStorageBuilder());\n\n            return partitionBuilder.build();\n        }\n    }\n\n    private static final class StorageConverter\n    {","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/glue/converter/GlueToPrestoConverter.java#L147-L183","documentation":"Companion check of apply(): the Glue Partition's tableName must equal the table whose partitions were requested; otherwise IllegalArgumentException('Unexpected tableName...') is thrown, guarding against partitions associated with the wrong table.","triggerScenarios":"Reading partitions when Glue returns a Partition whose tableName differs from the requested table name.","commonSituations":"Orphaned partitions left by table drops/renames, corrupted Glue metadata, or converter misuse with partitions of another table.","solutions":["Repair or delete the mismatched Glue partition entries","Re-run the partition listing against the intended table","Audit table rename/drop workflows that leave inconsistent partitions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!tableName.equals(gluePartition.tableName())) {\n    // skip or repair partition fetched with mismatched tableName\n    return null;\n}","typeGuard":"boolean partitionMatches(Partition p, String db, String tbl) {\n    return db.equals(p.databaseName()) && tbl.equals(p.tableName());\n}","tryCatchPattern":"try {\n    Partition part = prestoPartition(gluePartition, ...);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Unexpected tableName\")) {\n        // log and skip inconsistent partition\n    } else throw e;\n}","preventionTips":["Purge stale partitions when tables are dropped/recreated","Verify batch partition fetches return partitions of the requested table"],"tags":["glue","partition","metadata-validation","illegal-argument"],"backgroundTag":"partition-metadata-mismatch","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"}