{"record":{"id":"0b1037b82a3b56dd","repo":"prestodb/presto","slug":"writing-to-skewed-table-partition-is-not-supported-0b1037","errorCode":null,"errorMessage":"Writing to skewed table/partition is not supported","messagePattern":"Writing to skewed table/partition is not supported","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/thrift/ThriftMetastoreUtil.java","lineNumber":701,"sourceCode":"    public static void fromMetastoreApiStorageDescriptor(StorageDescriptor storageDescriptor, Storage.Builder builder, String tablePartitionName)\n    {\n        SerDeInfo serdeInfo = storageDescriptor.getSerdeInfo();\n        if (serdeInfo == null) {\n            throw new PrestoException(HIVE_INVALID_METADATA, \"Table storage descriptor is missing SerDe info\");\n        }\n\n        builder.setStorageFormat(StorageFormat.createNullable(serdeInfo.getSerializationLib(), storageDescriptor.getInputFormat(), storageDescriptor.getOutputFormat()))\n                .setLocation(nullToEmpty(storageDescriptor.getLocation()))\n                .setBucketProperty(HiveBucketProperty.fromStorageDescriptor(storageDescriptor, tablePartitionName))\n                .setSkewed(storageDescriptor.isSetSkewedInfo() && storageDescriptor.getSkewedInfo().isSetSkewedColNames() && !storageDescriptor.getSkewedInfo().getSkewedColNames().isEmpty())\n                .setSerdeParameters(serdeInfo.getParameters() == null ? ImmutableMap.of() : serdeInfo.getParameters())\n                .setParameters(storageDescriptor.getParameters() == null ? ImmutableMap.of() : storageDescriptor.getParameters());\n    }\n\n    private static StorageDescriptor makeStorageDescriptor(String tableName, List<Column> columns, Storage storage, ColumnConverter columnConverter)\n    {\n        if (storage.isSkewed()) {\n            throw new IllegalArgumentException(\"Writing to skewed table/partition is not supported\");\n        }\n        SerDeInfo serdeInfo = new SerDeInfo();\n        serdeInfo.setName(tableName);\n        serdeInfo.setSerializationLib(storage.getStorageFormat().getSerDeNullable());\n        serdeInfo.setParameters(storage.getSerdeParameters());\n\n        StorageDescriptor sd = new StorageDescriptor();\n        sd.setLocation(emptyToNull(storage.getLocation()));\n        sd.setCols(columns.stream()\n                .map(col -> ThriftMetastoreUtil.toMetastoreApiFieldSchema(col, columnConverter))\n                .collect(toList()));\n        sd.setSerdeInfo(serdeInfo);\n        sd.setInputFormat(storage.getStorageFormat().getInputFormatNullable());\n        sd.setOutputFormat(storage.getStorageFormat().getOutputFormatNullable());\n        sd.setParameters(storage.getParameters());\n\n        Optional<HiveBucketProperty> bucketProperty = storage.getBucketProperty();\n        if (bucketProperty.isPresent()) {","sourceCodeStart":683,"sourceCodeEnd":719,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/thrift/ThriftMetastoreUtil.java#L683-L719","documentation":"makeStorageDescriptor builds the Metastore StorageDescriptor when writing table/partition metadata. Presto's write path does not support skewed table layouts, so if the target Storage has isSkewed() set, it throws IllegalArgumentException. Skewed tables (rows for certain values stored in separate directories) can be read but not created/written through this connector.","triggerScenarios":"Attempting CREATE TABLE ... SKEWED BY (...) or writing/altering into a table/partition that Presto metadata marked as skewed — makeStorageDescriptor is called on every createTable/finishInsert/commit path.","commonSituations":"Migrating a skewed Hive table to Presto and trying to write to it; CTAS or INSERT into a table whose source definition was skewed; schema copy tools that clone skewed properties.","solutions":["Remove the skew specification: recreate the table without SKEWED BY and write to that","Use Hive to write to skewed tables; keep Presto reads only","If skew definition is unnecessary, ALTER TABLE ... SET SKEWED LOCATION / unset skewed properties in Hive before writing via Presto"],"exampleFix":"-- before\nCREATE TABLE t (a int) SKEWED BY (a) ON ((1)) STORED AS DIRECTORIES;\n-- after\nCREATE TABLE t (a int) STORED AS PARQUET; -- no SKEWED BY","handlingStrategy":"validation","validationCode":"// check before writing via Presto\nTable hiveTable = metastore.getTable(db, table).orElseThrow(...);\nboolean skewed = hiveTable.getParameters().containsKey(\"SKEWED\")\n    || (hiveTable.getSd() != null && hiveTable.getSd().isSetSkewedInfo());\nif (skewed) {\n    throw new PrestoException(NOT_SUPPORTED, \"Route writes to \" + table + \" through Hive; skewed tables unsupported\");\n}","typeGuard":"boolean isSkewedStorage(Storage storage) {\n    return storage != null && storage.isSkewed();\n}","tryCatchPattern":"try {\n    insert/ctas into target table;\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"skewed table/partition\")) {\n        throw new PrestoException(NOT_SUPPORTED,\n            \"Target is a skewed Hive table; write via Hive or recreate without SKEWED BY\", e);\n    }\n    throw e;\n}","preventionTips":["Avoid SKEWED BY in DDL for tables Presto must write","Clone table schemas without skewed properties when migrating","Use Hive for writes to legacy skewed tables"],"tags":["hive","skewed-table","write-unsupported"],"backgroundTag":"unsupported-hive-table-feature","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"}