{"record":{"id":"3eb52fd8da0b0976","repo":"prestodb/presto","slug":"not-supported-3eb52f","errorCode":"NOT_SUPPORTED","errorMessage":"Inserting into bucketed tables with skew is not supported. %s","messagePattern":"Inserting into bucketed tables with skew is not supported\\. (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/HiveWriteUtils.java","lineNumber":405,"sourceCode":"            Map<String, String> parameters,\n            Storage storage)\n    {\n        String tablePartitionDescription = \"Table '\" + tableName + \"'\";\n        if (partitionName.isPresent()) {\n            tablePartitionDescription += \" partition '\" + partitionName.get() + \"'\";\n        }\n\n        // verify online\n        verifyOnline(tableName, partitionName, protectMode, parameters);\n\n        // verify not read only\n        if (protectMode.readOnly) {\n            throw new HiveReadOnlyException(tableName, partitionName);\n        }\n\n        // verify skew info\n        if (storage.isSkewed()) {\n            throw new PrestoException(NOT_SUPPORTED, format(\"Inserting into bucketed tables with skew is not supported. %s\", tablePartitionDescription));\n        }\n    }\n\n    public static Path getTableDefaultLocation(ConnectorSession session, SemiTransactionalHiveMetastore metastore, HdfsEnvironment hdfsEnvironment, String schemaName, String tableName)\n    {\n        MetastoreContext metastoreContext = new MetastoreContext(\n                session.getIdentity(),\n                session.getQueryId(),\n                session.getClientInfo(),\n                session.getClientTags(),\n                session.getSource(),\n                getMetastoreHeaders(session),\n                isUserDefinedTypeEncodingEnabled(session),\n                metastore.getColumnConverterProvider(),\n                session.getWarningCollector(),\n                session.getRuntimeStats());\n        Optional<String> location = getDatabase(session.getIdentity(), metastoreContext, metastore, schemaName).getLocation();\n        if (!location.isPresent() || location.get().isEmpty()) {","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/HiveWriteUtils.java#L387-L423","documentation":"checkWritable refuses writes to Hive tables/partitions that are both bucketed and skewed. Presto's bucketing writer cannot preserve the skewed-bucket layout the table declares, so writing would corrupt bucketing invariants. The exception carries the table/partition description for diagnosis.","triggerScenarios":"INSERT (or CTAS writing into an existing table) whose target HiveTableHandle/storage has isSkewed() true — i.e. the table was created with SKEWED BY and is also bucketed (CLUSTERED BY ... INTO N BUCKETS).","commonSituations":"Inserting into legacy Hive tables defined with SKEWED BY clause created outside Presto; schema migration bringing skewed bucketed tables into a Presto write path.","solutions":["Remove the skew specification: recreate the table without SKEWED BY, copy data, and swap names","Write to a different (non-skewed) staging table from Presto, then load into the skewed table via Hive itself","If skew metadata is stale, drop the skew info in the metastore (ALTER TABLE ... NOT SKEWED / update table properties) if it no longer reflects reality"],"exampleFix":"// before\nCREATE TABLE t (k int) CLUSTERED BY (k) INTO 4 BUCKETS SKEWED BY (k) ON (1,2); -- insert fails\n// after\nCREATE TABLE t (k int) CLUSTERED BY (k) INTO 4 BUCKETS;","handlingStrategy":"validation","validationCode":"Table t = metastore.getTable(schema, table);\nif (t.getStorage().isSkewed() && t.getStorage().getBucketProperty().isPresent()) {\n    throw new IllegalStateException(\"Target table is bucketed+skewed; not writable from Presto\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    insertInto(skewedTable);\n} catch (PrestoException e) {\n    if (NOT_SUPPORTED.toErrorCode().equals(e.getErrorCode()) && e.getMessage().contains(\"bucketed tables with skew\")) {\n        // fall back to a staging non-skewed table\n    } else throw e;\n}","preventionTips":["Avoid SKEWED BY on tables Presto must write to","Prefer LIST_BUCKETING-free, plain bucketed or unbucketed tables for Presto ingestion","Audit legacy Hive DDL for skew before migrating write paths to Presto"],"tags":["hive","bucketing","skew","not-supported"],"backgroundTag":"unsupported-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"}