prestodb/presto · error · IllegalArgumentException
valueIsNull length is less than positionCount
Error message
valueIsNull length is less than positionCount
What it means
When a VariableWidthBlock carries nullability info, the valueIsNull boolean array must have one entry per position (valueIsNull.length - arrayOffset >= positionCount). A short array cannot record null-ness for all positions, so the constructor throws IllegalArgumentException.
Source
Thrown at presto-common/src/main/java/com/facebook/presto/common/block/VariableWidthBlock.java:90
}
this.arrayOffset = arrayOffset;
if (positionCount < 0) {
throw new IllegalArgumentException("positionCount is negative");
}
this.positionCount = positionCount;
if (slice == null) {
throw new IllegalArgumentException("slice is null");
}
this.slice = slice;
if (offsets.length - arrayOffset < (positionCount + 1)) {
throw new IllegalArgumentException("offsets length is less than positionCount");
}
this.offsets = offsets;
if (valueIsNull != null && valueIsNull.length - arrayOffset < positionCount) {
throw new IllegalArgumentException("valueIsNull length is less than positionCount");
}
this.valueIsNull = valueIsNull;
sizeInBytes = offsets[arrayOffset + positionCount] - offsets[arrayOffset] + ((Integer.BYTES + Byte.BYTES) * (long) positionCount);
retainedSizeInBytes = INSTANCE_SIZE + slice.getRetainedSize() + sizeOf(valueIsNull) + sizeOf(offsets);
}
@Override
public final int getPositionOffset(int position)
{
return offsets[position + arrayOffset];
}
@Override
public int getSliceLength(int position)
{
checkReadablePosition(position);
return getSliceLengthUnchecked(position + arrayOffset);View on GitHub (pinned to 55bb57d202)
Solutions
- Size valueIsNull to at least arrayOffset + positionCount entries before construction.
- Pass null only when the block genuinely has no null values; otherwise keep the array aligned with positionCount.
- Audit the page-reading path for null-vector/data misalignment.
Example fix
// before boolean[] valueIsNull = new boolean[positions - 1]; // too short new VariableWidthBlock(0, positions, slice, offsets, valueIsNull); // after boolean[] valueIsNull = new boolean[positions]; new VariableWidthBlock(0, positions, slice, offsets, valueIsNull);
Defensive patterns
Strategy: validation
Validate before calling
checkState(valueIsNull == null || valueIsNull.length - arrayOffset >= positionCount,
"valueIsNull too short for %s positions", positionCount); Try / catch
try {
new VariableWidthBlock(arrayOffset, positionCount, slice, offsets, valueIsNull);
} catch (IllegalArgumentException e) {
// realign null vector with positionCount
} Prevention
- Size null vectors from the same position count used for the block
- Pass null only when the block has no nulls; otherwise keep arrays aligned
- Audit column readers for null-vector/data chunk misalignment
When it happens
Trigger: Constructing VariableWidthBlock with a non-null valueIsNull array shorter than arrayOffset + positionCount; e.g. reusing a null vector from a different-sized block or from a page read with mismatched chunk sizes.
Common situations: Column-reader code misaligning definition/null levels with data values; hand-written blocks in tests or connectors where valueIsNull was sized without the null count.
Related errors
- Offset is not monotonically ascending. offsets[%s]=%s, offse
- A null map must have zero entries
- Number of fields in RowBlock must be positive
- position is not valid
- position is not valid
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/7b70ee69fe8dc4b1.
Report an issue: GitHub.