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
- Correct the type mapping so TimeStampMicro columns map to Presto TimestampType
- Refresh schema metadata so the declared column type matches the Arrow vector
- Cast the column to timestamp on the producer side if the target type intentionally differs
- 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
- Map Arrow timestamp columns to Presto TIMESTAMP in the catalog, never BIGINT
- Re-derive column types whenever the upstream Arrow schema changes
- Use a central arrowTypeToPrestoType(field) helper for all mappings
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
- Type must be a DecimalType for DecimalVector
- Expected VarcharType but got {type.getClass().getName()}
- Expected DateType but got {type.getClass().getName()}
- Type must be a TimeType for TimeSecVector
- Unsupported FieldVector type: {fieldVector.getClass()}
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/beb8367a8d0b307e.
Report an issue: GitHub.