prestodb/presto · error · IllegalArgumentException
Unexpected partitioning:
Error message
Unexpected partitioning:
What it means
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.
Source
Thrown at presto-spark-base/src/main/java/com/facebook/presto/spark/execution/AbstractPrestoSparkQueryExecution.java:337
protected static Partitioner createPartitioner(PartitioningScheme partitioningScheme)
{
PartitioningHandle partitioning = partitioningScheme.getPartitioning().getHandle();
if (partitioning.equals(SINGLE_DISTRIBUTION)) {
return new PrestoSparkPartitioner(1);
}
if (partitioning.equals(FIXED_HASH_DISTRIBUTION)
|| partitioning.equals(FIXED_ARBITRARY_DISTRIBUTION)
|| partitioning.getConnectorId().isPresent()) {
int[] bucketToPartition = partitioningScheme.getBucketToPartition().orElseThrow(
() -> new IllegalArgumentException("bucketToPartition is expected to be assigned at this point"));
checkArgument(bucketToPartition.length > 0, "bucketToPartition is expected to be non empty");
int numberOfPartitions = IntStream.of(bucketToPartition)
.max()
.getAsInt() + 1;
return new PrestoSparkPartitioner(numberOfPartitions);
}
throw new IllegalArgumentException("Unexpected partitioning: " + partitioning);
}
@Override
public List<List<Object>> execute()
{
List<Tuple2<MutablePartitionId, PrestoSparkSerializedPage>> rddResults;
try {
tuneMaxExecutorsCount();
rddResults = doExecute();
queryStateTimer.beginFinishing();
PrestoSparkTransactionUtils.commit(session, transactionManager);
queryStateTimer.endQuery();
}
catch (Throwable executionException) {
queryStateTimer.beginFinishing();
try {
PrestoSparkTransactionUtils.rollback(session, transactionManager);
}View on GitHub (pinned to 55bb57d202)
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
Example fix
// before
throw new IllegalArgumentException("Unexpected partitioning: " + partitioning);
// after: handle the scheme explicitly before the throw, e.g.
if (partitioning.getHandle().equals(HASH_DISTRIBUTED)) {
return new PrestoSparkPartitioner(numberOfPartitions);
}
throw new IllegalArgumentException("Unexpected partitioning: " + partitioning); Defensive patterns
Strategy: validation
Validate before calling
Partitioning p = ...;
Set<PartitioningHandle> supported = ImmutableSet.of(HASH_DISTRIBUTED.getHandle(), SINGLE_DISTRIBUTION.getHandle(), FIXED_BROADCAST_DISTRIBUTION.getHandle());
if (!supported.contains(p.getHandle())) throw new IllegalArgumentException("unsupported: " + p); Type guard
boolean isSupportedPartitioning(Partitioning partitioning) {
PartitioningHandle h = partitioning.getHandle();
return h.equals(HASH_DISTRIBUTED.getHandle()) || h.equals(SINGLE_DISTRIBUTION.getHandle()) || h.equals(FIXED_BROADCAST_DISTRIBUTION.getHandle());
} Try / catch
try {
Partitioner partitioner = execution.partitioner();
}
catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Unexpected partitioning:")) {
// fail fast with plan dump for planner debugging
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- shuffleWriteInfo and broadcastBasePath can not be specified
- Unexpected partition: %s. Total number of partitions: %s.
- Invalid day-time interval:
- Invalid year-month interval:
- dictionarySourceIds must be the same
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/f3001fbeac32f3fb.
Report an issue: GitHub.