prestodb/presto · error · IllegalArgumentException

Type must be an ArrayType for ListVector

Error message

Type must be an ArrayType for ListVector

What it means

assignBlockFromListVector converts an Arrow ListVector into a Presto array block. It needs the Presto Type to be ArrayType so it can extract the element type for recursive conversion; if the Type is anything else (scalar, RowType, MapType), the conversion cannot proceed and this IllegalArgumentException is thrown.

Source

Thrown at presto-common-arrow/src/main/java/com/facebook/plugin/arrow/ArrowBlockBuilder.java:659

        if (!(type instanceof TimestampType)) {
            throw new IllegalArgumentException("Type must be a TimestampType for TimeStampMilliTZVector");
        }

        for (int i = startIndex; i < endIndex; i++) {
            if (vector.isNull(i)) {
                builder.appendNull();
            }
            else {
                long millis = vector.get(i);
                type.writeLong(builder, millis);
            }
        }
    }

    public void assignBlockFromListVector(ListVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)
    {
        if (!(type instanceof ArrayType)) {
            throw new IllegalArgumentException("Type must be an ArrayType for ListVector");
        }

        ArrayType arrayType = (ArrayType) type;
        Type elementType = arrayType.getElementType();

        for (int i = startIndex; i < endIndex; i++) {
            if (vector.isNull(i)) {
                builder.appendNull();
            }
            else {
                BlockBuilder elementBuilder = builder.beginBlockEntry();
                assignBlockFromValueVector(
                        vector.getDataVector(), elementType, elementBuilder, vector.getElementStartIndex(i), vector.getElementEndIndex(i));
                builder.closeEntry();
            }
        }
    }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Declare the Presto column as an array of the matching element type (ArrayType)
  2. Fix the Type passed to this method in the dispatch path so the list column gets its own ArrayType
  3. Check the Arrow field vs Presto column alignment (names/indices) that feeds assignBlockFromValueVector

Example fix

// before
assignBlockFromListVector(listVector, MapType, builder, start, end);
// after
assignBlockFromListVector(listVector, ArrayType.from(elementType), builder, start, end);
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(columnType instanceof ArrayType)) {
    throw new IllegalStateException("Column '" + name + "' must be ArrayType to receive ListVector, got " + columnType);
}

Type guard

boolean isArrayColumn(Type type) {
    return type instanceof ArrayType;
}

Try / catch

try {
    builder.assignBlockFromListVector(vector, type, blockBuilder, start, end);
} catch (IllegalArgumentException e) {
    if (!e.getMessage().contains("ArrayType for ListVector")) throw e;
    // fall back to a type-coercing reader or error out with context
}

Prevention

When it happens

Trigger: Calling assignBlockFromListVector (directly or via assignBlockFromValueVector) with a non-ArrayType, e.g. a MAP or ROW declared column receiving a ListVector, or a VARCHAR column whose values were encoded as lists.

Common situations: Arrow schema declares a list column but the Presto table was created with the wrong column type (e.g. json or row instead of array); nested-type dispatch bugs where LIST vectors get paired with the parent row's type.

Related errors


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