{"record":{"id":"f3001fbeac32f3fb","repo":"prestodb/presto","slug":"unexpected-partitioning","errorCode":null,"errorMessage":"Unexpected partitioning: ","messagePattern":"Unexpected partitioning: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-spark-base/src/main/java/com/facebook/presto/spark/execution/AbstractPrestoSparkQueryExecution.java","lineNumber":337,"sourceCode":"\n    protected static Partitioner createPartitioner(PartitioningScheme partitioningScheme)\n    {\n        PartitioningHandle partitioning = partitioningScheme.getPartitioning().getHandle();\n        if (partitioning.equals(SINGLE_DISTRIBUTION)) {\n            return new PrestoSparkPartitioner(1);\n        }\n        if (partitioning.equals(FIXED_HASH_DISTRIBUTION)\n                || partitioning.equals(FIXED_ARBITRARY_DISTRIBUTION)\n                || partitioning.getConnectorId().isPresent()) {\n            int[] bucketToPartition = partitioningScheme.getBucketToPartition().orElseThrow(\n                    () -> new IllegalArgumentException(\"bucketToPartition is expected to be assigned at this point\"));\n            checkArgument(bucketToPartition.length > 0, \"bucketToPartition is expected to be non empty\");\n            int numberOfPartitions = IntStream.of(bucketToPartition)\n                    .max()\n                    .getAsInt() + 1;\n            return new PrestoSparkPartitioner(numberOfPartitions);\n        }\n        throw new IllegalArgumentException(\"Unexpected partitioning: \" + partitioning);\n    }\n\n    @Override\n    public List<List<Object>> execute()\n    {\n        List<Tuple2<MutablePartitionId, PrestoSparkSerializedPage>> rddResults;\n        try {\n            tuneMaxExecutorsCount();\n            rddResults = doExecute();\n            queryStateTimer.beginFinishing();\n            PrestoSparkTransactionUtils.commit(session, transactionManager);\n            queryStateTimer.endQuery();\n        }\n        catch (Throwable executionException) {\n            queryStateTimer.beginFinishing();\n            try {\n                PrestoSparkTransactionUtils.rollback(session, transactionManager);\n            }","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-spark-base/src/main/java/com/facebook/presto/spark/execution/AbstractPrestoSparkQueryExecution.java#L319-L355","documentation":"Thrown from AbstractPrestoSparkQueryExecution.createPartitioner() when the plan's Partitioning is not one of the supported Spark partitioning schemes (e.g. HASH/SINGLE/FIXED_BROADCAST). This is a programming/invariant error: the query execution received a partitioning handle the Spark execution engine cannot map to a PrestoSparkPartitioner.","triggerScenarios":"partitioner() is called with a Partitioning handle that does not match any expected case, so control reaches the final throw new IllegalArgumentException(\"Unexpected partitioning: \" + partitioning).","commonSituations":"Custom connectors or planner extensions emitting an unsupported partitioning; version mismatches where a new partitioning type is produced upstream but the Spark execution path was not updated.","solutions":["Log/inspect the partitioning handle value in the message to see which unsupported scheme was produced","Ensure the query plan is produced by the standard Presto-on-Spark planner without custom partitioning extensions","Upgrade coordinator/worker jars so planner and Spark execution agree on supported partitioning types","If adding a new partitioning type, extend createPartitioner to handle it"],"exampleFix":"// before\nthrow new IllegalArgumentException(\"Unexpected partitioning: \" + partitioning);\n// after: handle the scheme explicitly before the throw, e.g.\nif (partitioning.getHandle().equals(HASH_DISTRIBUTED)) {\n    return new PrestoSparkPartitioner(numberOfPartitions);\n}\nthrow new IllegalArgumentException(\"Unexpected partitioning: \" + partitioning);","handlingStrategy":"validation","validationCode":"Partitioning p = ...;\nSet<PartitioningHandle> supported = ImmutableSet.of(HASH_DISTRIBUTED.getHandle(), SINGLE_DISTRIBUTION.getHandle(), FIXED_BROADCAST_DISTRIBUTION.getHandle());\nif (!supported.contains(p.getHandle())) throw new IllegalArgumentException(\"unsupported: \" + p);","typeGuard":"boolean isSupportedPartitioning(Partitioning partitioning) {\n    PartitioningHandle h = partitioning.getHandle();\n    return h.equals(HASH_DISTRIBUTED.getHandle()) || h.equals(SINGLE_DISTRIBUTION.getHandle()) || h.equals(FIXED_BROADCAST_DISTRIBUTION.getHandle());\n}","tryCatchPattern":"try {\n    Partitioner partitioner = execution.partitioner();\n}\ncatch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Unexpected partitioning:\")) {\n        // fail fast with plan dump for planner debugging\n    }\n    throw e;\n}","preventionTips":["Avoid custom planner extensions that emit novel partitioning handles","Keep planner and Spark execution modules on the same version","When adding partitioning types, update createPartitioner in the same change","Log the partitioning handle during plan validation"],"tags":["spark","partitioning","illegal-argument","planner"],"backgroundTag":"unsupported-partitioning","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"}