prestodb/presto · error · IllegalArgumentException

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

Error message

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

What it means

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.

Source

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

        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();
        }
    }

    private static final class StorageConverter
    {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Repair or delete the mismatched Glue partition entries
  2. Re-run the partition listing against the intended table
  3. Audit table rename/drop workflows that leave inconsistent partitions
Defensive patterns

Strategy: validation

Validate before calling

if (!tableName.equals(gluePartition.tableName())) {
    // skip or repair partition fetched with mismatched tableName
    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 tableName")) {
        // log and skip inconsistent partition
    } else throw e;
}

Prevention

When it happens

Trigger: Reading partitions when Glue returns a Partition whose tableName differs from the requested table name.

Common situations: Orphaned partitions left by table drops/renames, corrupted Glue metadata, or converter misuse with partitions of another table.

Related errors


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