{"record":{"id":"2641cea69fd42111","repo":"prestodb/presto","slug":"unexpected-databasename-expected-s-but-found","errorCode":null,"errorMessage":"Unexpected databaseName, expected: %s, but found: %s","messagePattern":"Unexpected databaseName, 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":162,"sourceCode":"        private final Function<Map<String, String>, Map<String, String>> parametersConverter = parametersConverter();\n        private final StorageConverter storageConverter = new StorageConverter();\n        private final String databaseName;\n        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    }","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/glue/converter/GlueToPrestoConverter.java#L144-L180","documentation":"GlueToPrestoConverter's partition-mapping apply() validates that each Glue Partition belongs to the database the query was made against. A mismatch (partition's databaseName differs from the enclosing table's) throws IllegalArgumentException to surface inconsistent catalog data.","triggerScenarios":"Listing/reading partitions where a returned Glue Partition has a databaseName different from the requested database — inconsistent Glue metadata or API anomaly.","commonSituations":"Corrupted Glue catalog entries, table renames leaving orphan partitions, or misuse of the converter with partitions fetched for another table.","solutions":["Verify and repair the Glue partition entries so databaseName matches the parent table","Re-fetch partitions for the correct database/table","Upgrade/check the connector path that fetched partitions from another database"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!databaseName.equals(gluePartition.databaseName())) {\n    // skip or repair partition fetched with mismatched databaseName\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 databaseName\")) {\n        // log and skip inconsistent partition\n    } else throw e;\n}","preventionTips":["Clean up orphaned partitions after table renames/drops","Fetch partitions only via the owning table's API path","Periodically validate partition ownership in Glue"],"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"}