prestodb/presto · error · IllegalArgumentException

offsets length is less than positionCount

Error message

offsets length is less than positionCount

What it means

Validation guard in ArrayBlock's constructor-argument checker: the offsets array is too short to hold positionCount+1 entries, so element boundaries cannot be resolved. Like the other checks in validateConstructorArguments, it indicates an internal caller built the offsets array with the wrong length.

Source

Thrown at presto-common/src/main/java/com/facebook/presto/common/block/ArrayBlock.java:91

    }

    private static void validateConstructorArguments(int arrayOffset, int positionCount, @Nullable boolean[] valueIsNull, int[] offsets, Block values)
    {
        if (arrayOffset < 0) {
            throw new IllegalArgumentException("arrayOffset is negative");
        }

        if (positionCount < 0) {
            throw new IllegalArgumentException("positionCount is negative");
        }

        if (valueIsNull != null && valueIsNull.length - arrayOffset < positionCount) {
            throw new IllegalArgumentException("isNull length is less than positionCount");
        }

        requireNonNull(offsets, "offsets is null");
        if (offsets.length - arrayOffset < positionCount + 1) {
            throw new IllegalArgumentException("offsets length is less than positionCount");
        }

        requireNonNull(values, "values is null");
    }

    /**
     * Use createArrayBlockInternal or fromElementBlock instead of this method.  The caller of this method is assumed to have
     * validated the arguments with validateConstructorArguments.
     */
    private ArrayBlock(int arrayOffset, int positionCount, @Nullable boolean[] valueIsNull, int[] offsets, Block values)
    {
        // caller must check arguments with validateConstructorArguments
        this.arrayOffset = arrayOffset;
        this.positionCount = positionCount;
        this.valueIsNull = valueIsNull;
        this.offsets = offsets;
        this.values = requireNonNull(values);

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Ensure the offsets array has at least positionCount + 1 entries
  2. Fix the producer that sized or populated the offsets array
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at presto-common/src/main/java/com/facebook/presto/common/block/ArrayBlock.java:91 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/0be5c9dcffff9232. Report an issue: GitHub.