prestodb/presto · error · IllegalArgumentException

Expected DateType but got {type.getClass().getName()}

Error message

Expected DateType but got {type.getClass().getName()}

What it means

assignBlockFromDateDayVector expects the paired Presto Type to be DateType because it converts Arrow day-granularity dates (days since epoch) into Presto date blocks. If type is not a DateType it throws IllegalArgumentException('Expected DateType but got <class>').

Source

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

        for (int i = startIndex; i < endIndex; i++) {
            if (vector.isNull(i)) {
                builder.appendNull();
            }
            else {
                // Directly create a Slice from the raw byte array
                byte[] rawBytes = vector.get(i);
                Slice slice = Slices.wrappedBuffer(rawBytes);
                // Write the Slice directly to the builder
                type.writeSlice(builder, slice);
            }
        }
    }

    public void assignBlockFromDateDayVector(DateDayVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)
    {
        if (!(type instanceof DateType)) {
            throw new IllegalArgumentException("Expected DateType but got " + type.getClass().getName());
        }

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

    public void assignBlockFromDateMilliVector(DateMilliVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)
    {
        if (!(type instanceof DateType)) {
            throw new IllegalArgumentException("Expected DateType but got " + type.getClass().getName());
        }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Correct the mapping so DateDay columns map to Presto DateType
  2. Refresh the connector's schema/table metadata
  3. Cast the column to date on the producer side if the declared type differs intentionally
  4. Assert type instanceof DateType before invoking the assign method in custom code

Example fix

// before
Type type = BIGINT; // wrong for DateDayVector
// after
Type type = DateType.DATE;
Defensive patterns

Strategy: validation

Validate before calling

checkArgument(type instanceof DateType,
    "Column %s is DateDayVector but declared type is %s", vector.getName(), type.getDisplayName());

Type guard

boolean isCompatiblePrestoType(ValueVector v, Type t) {
    if (v instanceof DateDayVector) {
        return t instanceof DateType;
    }
    return true;
}

Try / catch

try {
    blockBuilder.assignBlockFromDateDayVector(dateDayVector, type, builder, 0, n);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Expected DateType")) {
        throw new SchemaMismatchException(vector.getName(), type, "DATE", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: assignBlockFromValueVector dispatches a DateDayVector while the mapped Type is not DateType — e.g. it was mapped to DATE's underlying integer type, TIMESTAMP, or BIGINT.

Common situations: Date columns mapped to integer/timestamp in the connector catalog; schema metadata out of sync with the Arrow data; custom code passing epoch-day values as bigint with a BIGINT type.

Related errors


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