prestodb/presto · error · IllegalArgumentException

Unexpected databaseName, expected

Error message

Unexpected databaseName, expected: %s, but found: %s

What it means

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.

Solutions

  1. Verify and repair the Glue partition entries so databaseName matches the parent table
  2. Re-fetch partitions for the correct database/table
  3. Upgrade/check the connector path that fetched partitions from another database
Defensive patterns

Strategy: validation

Validate before calling

if (!databaseName.equals(gluePartition.databaseName())) {
    // skip or repair partition fetched with mismatched databaseName
    return null;
}

Type guard

boolean partitionMatches(Partition p, String db, String tbl) {
    return db.equals(p.databaseName()) && tbl.equals(p.tableName());
}

Try / catch

try {
    Partition part = prestoPartition(gluePartition, ...);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Unexpected databaseName")) {
        // log and skip inconsistent partition
    } else throw e;
}

Prevention

When it happens

Trigger: Listing/reading partitions where a returned Glue Partition has a databaseName different from the requested database — inconsistent Glue metadata or API anomaly.

Common situations: Corrupted Glue catalog entries, table renames leaving orphan partitions, or misuse of the converter with partitions fetched for another table.

Related errors


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

Appendix: source

Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/glue/converter/GlueToPrestoConverter.java:162

        private final Function<Map<String, String>, Map<String, String>> parametersConverter = parametersConverter();
        private final StorageConverter storageConverter = new StorageConverter();
        private final String databaseName;
        private final String tableName;

        public GluePartitionConverter(String databaseName, String tableName)
        {
            this.databaseName = requireNonNull(databaseName, "databaseName is null");
            this.tableName = requireNonNull(tableName, "tableName is null");
        }

        @Override
        public Partition apply(software.amazon.awssdk.services.glue.model.Partition gluePartition)
        {
            requireNonNull(gluePartition.storageDescriptor(), "Partition StorageDescriptor is null");
            StorageDescriptor sd = gluePartition.storageDescriptor();

            if (!databaseName.equals(gluePartition.databaseName())) {
                throw new IllegalArgumentException(format("Unexpected databaseName, expected: %s, but found: %s", databaseName, gluePartition.databaseName()));
            }
            if (!tableName.equals(gluePartition.tableName())) {
                throw new IllegalArgumentException(format("Unexpected tableName, expected: %s, but found: %s", tableName, gluePartition.tableName()));
            }

            Partition.Builder partitionBuilder = Partition.builder()
                    .setCatalogName(Optional.empty())
                    .setDatabaseName(databaseName)
                    .setTableName(tableName)
                    .setValues(gluePartition.values()) // No memoization benefit
                    .setColumns(columnsConverter.apply(sd.columns()))
                    .setParameters(parametersConverter.apply(gluePartition.parameters()));

            storageConverter.setConvertedStorage(sd, partitionBuilder.getStorageBuilder());

            return partitionBuilder.build();
        }
    }

View on GitHub (pinned to 55bb57d202)