prestodb/presto · error · IllegalArgumentException
Can not grow array beyond '%s'
Error message
Can not grow array beyond '%s'
What it means
UnnestOperatorBlockUtil.calculateNewArraySize grows internal block builder arrays geometrically, capping growth at MAX_ARRAY_SIZE. If the current array is already at the cap and a larger size is still requested, growth is impossible and an IllegalArgumentException is thrown.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/operator/unnest/UnnestOperatorBlockUtil.java:39
private static final int DEFAULT_CAPACITY = 64;
// See java.util.ArrayList for an explanation
static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
// Copied from io.prestosql.spi.block.BlockUtil#calculateNewArraySize
static int calculateNewArraySize(int currentSize)
{
// grow array by 50%
long newSize = (long) currentSize + (currentSize >> 1);
// verify new size is within reasonable bounds
if (newSize < DEFAULT_CAPACITY) {
newSize = DEFAULT_CAPACITY;
}
else if (newSize > MAX_ARRAY_SIZE) {
newSize = MAX_ARRAY_SIZE;
if (newSize == currentSize) {
throw new IllegalArgumentException(format("Can not grow array beyond '%s'", MAX_ARRAY_SIZE));
}
}
return (int) newSize;
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Reduce unnest fan-out: add a LIMIT, filter rows, or unnest smaller arrays.
- Split the work into multiple smaller queries/batches instead of one giant unnest.
- Increase query max memory limits so results can be spooled differently, or restructure to aggregate instead of replicate.
Defensive patterns
Strategy: validation
Validate before calling
-- bound unnest fan-out before running: -- SELECT count(*) * max(cardinality(arr)) over () FROM t; ensure far below 2^30
Prevention
- Avoid cross-joins with huge arrays; add LIMIT or filters.
- Estimate total replicated element count before unnesting.
- Break oversized workloads into batches.
When it happens
Trigger: Unnesting extremely large collections such that an internal block builder array already at MAX_ARRAY_SIZE (~2^30-ish elements) is asked to grow further — e.g. unnesting billions of total replicated elements in one operator.
Common situations: Cross-joining many rows with huge arrays/maps, amplifying total element counts past the array cap; queries with missing LIMIT or heavy fan-out.
Related errors
- HIVE_EXCEEDED_SPLIT_BUFFERING_LIMIT
- GENERIC_INSUFFICIENT_RESOURCES
- GENERIC_SPILL_FAILURE
- Cannot unnest type:
- INVALID_FUNCTION_ARGUMENT
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/73c46095b063a139.
Report an issue: GitHub.