prestodb/presto · error · IllegalArgumentException

Writing to skewed table/partition is not supported

Error message

Writing to skewed table/partition is not supported

What it means

GlueInputConverter.convertStorage rejects any storage definition marked skewed. Hive skew specifications have no faithful mapping into the Glue StorageDescriptor conversion used for writes, so the converter fails fast with IllegalArgumentException.

Source

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

        PartitionInput input = convertPartition(partitionWithStatistics.getPartition());
        PartitionStatistics statistics = partitionWithStatistics.getStatistics();
        return input.toBuilder().parameters(updateStatisticsParameters(input.parameters(), statistics.getBasicStatistics()))
                .build();
    }

    public static PartitionInput convertPartition(Partition partition)
    {
        return PartitionInput.builder()
                .values(partition.getValues())
                .storageDescriptor(convertStorage(partition.getStorage(), partition.getColumns()))
                .parameters(partition.getParameters())
                .build();
    }

    private static StorageDescriptor convertStorage(Storage storage, List<Column> columns)
    {
        if (storage.isSkewed()) {
            throw new IllegalArgumentException("Writing to skewed table/partition is not supported");
        }
        SerDeInfo serDeInfo = SerDeInfo.builder()
                .serializationLibrary(storage.getStorageFormat().getSerDeNullable())
                .parameters(storage.getSerdeParameters())
                .build();

        StorageDescriptor.Builder sd = StorageDescriptor.builder()
                .location(storage.getLocation())
                .columns(columns.stream().map(GlueInputConverter::convertColumn).collect(toImmutableList()))
                .serdeInfo(serDeInfo)
                .inputFormat(storage.getStorageFormat().getInputFormatNullable())
                .outputFormat(storage.getStorageFormat().getOutputFormatNullable())
                .parameters(ImmutableMap.of());

        Optional<HiveBucketProperty> bucketProperty = storage.getBucketProperty();
        if (bucketProperty.isPresent()) {
            sd.numberOfBuckets(bucketProperty.get().getBucketCount());
            sd.bucketColumns(bucketProperty.get().getBucketedBy());

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Remove the SKEWED BY specification from the table and rewrite data unskewed
  2. Write to a different (non-skewed) table and swap via rename/partition exchange
  3. Drop and recreate the table without skew metadata

Example fix

// before
CREATE TABLE t (...) SKEWED BY (k) ON ('a','b');
// after
CREATE TABLE t (...); -- no SKEWED BY
Defensive patterns

Strategy: validation

Validate before calling

if (tableProperties.containsKey("SKEWED") || storage.isSkewed()) {
    throw new IllegalArgumentException("Cannot write: table/partition is skewed");
}
// proceed with write

Type guard

boolean writable = storage != null && !storage.isSkewed();

Try / catch

try {
    metastoreResult = convertPartition(glueTable, partition, path);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("skewed")) {
        // redirect write to non-skewed table or fail with guidance
    } else throw e;
}

Prevention

When it happens

Trigger: Creating or altering a table/partition (convertTable or convertPartition -> convertStorage) whose Storage has isSkewed() true, e.g. table with SKEWED BY clause.

Common situations: Writing to legacy Hive tables created with SKEWED BY / STORED AS DIRECTORIES that Presto reads but refuses to write back through Glue.

Related errors


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