prestodb/presto · error · IllegalArgumentException

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

Error message

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

What it means

assignBlockFromTimeStampMicroVector expects the paired Presto Type to be TimestampType since it converts microsecond timestamps to Presto timestamps. When type is not a TimestampType it throws IllegalArgumentException('Expected TimestampType but got <class>'). This is a vector-vs-declared-type mismatch, not a data corruption issue.

Source

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

                else {
                    Slice slice = Decimals.encodeScaledValue(decimal);
                    decimalType.writeSlice(builder, slice, 0, slice.length());
                }
            }
        }
    }

    public void assignBlockFromNullVector(NullVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)
    {
        for (int i = startIndex; i < endIndex; i++) {
            builder.appendNull();
        }
    }

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

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

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

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Correct the type mapping so TimeStampMicro columns map to Presto TimestampType
  2. Refresh schema metadata so the declared column type matches the Arrow vector
  3. Cast the column to timestamp on the producer side if the target type intentionally differs
  4. Confirm the Type argument passed in is derived from the same Arrow schema

Example fix

// before
Type type = BIGINT; // mismatch for TimeStampMicroVector
// after
Type type = TimestampType.TIMESTAMP;
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

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

Try / catch

try {
    blockBuilder.assignBlockFromTimeStampMicroVector(tsMicroVector, type, builder, 0, n);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Expected TimestampType")) {
        throw new SchemaMismatchException(vector.getName(), type, "TIMESTAMP", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: assignBlockFromValueVector dispatches a TimeStampMicroVector but the mapped Type resolved to something else (e.g. BIGINT, TimestampWithTimeZone, or DATE) because of an incorrect type mapping.

Common situations: Catalog/connector maps timestamp columns to bigint epoch; schema metadata stale after upstream changed timestamp units; custom conversion code passing the wrong Type for the vector.

Related errors


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