prestodb/presto · error · IllegalArgumentException
Type must be a TimeType for TimeSecVector
Error message
Type must be a TimeType for TimeSecVector
What it means
assignBlockFromTimeSecVector expects the paired Presto Type to be TimeType because it converts Arrow second-granularity times into Presto time blocks. If type is not a TimeType it throws IllegalArgumentException('Type must be a TimeType for TimeSecVector').
Source
Thrown at presto-common-arrow/src/main/java/com/facebook/plugin/arrow/ArrowBlockBuilder.java:544
throw new IllegalArgumentException("Expected DateType but got " + type.getClass().getName());
}
for (int i = startIndex; i < endIndex; i++) {
if (vector.isNull(i)) {
builder.appendNull();
}
else {
DateType dateType = (DateType) type;
long days = TimeUnit.MILLISECONDS.toDays(vector.get(i));
dateType.writeLong(builder, days);
}
}
}
public void assignBlockFromTimeSecVector(TimeSecVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)
{
if (!(type instanceof TimeType)) {
throw new IllegalArgumentException("Type must be a TimeType for TimeSecVector");
}
for (int i = startIndex; i < endIndex; i++) {
if (vector.isNull(i)) {
builder.appendNull();
}
else {
int value = vector.get(i);
long millis = TimeUnit.SECONDS.toMillis(value);
type.writeLong(builder, millis);
}
}
}
public void assignBlockFromTimeMilliVector(TimeMilliVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)
{
if (!(type instanceof TimeType)) {
throw new IllegalArgumentException("Type must be a TimeType for TimeSecVector");View on GitHub (pinned to 55bb57d202)
Solutions
- Fix the type mapping so Time columns map to Presto TimeType
- Refresh the connector's schema metadata
- Cast the producer column to time if the declared type differs intentionally
- Guard custom code with a TimeType instanceof check before calling
Example fix
// before Type type = BIGINT; // wrong for TimeSecVector // after Type type = TimeType.TIME;
Defensive patterns
Strategy: validation
Validate before calling
checkArgument(type instanceof TimeType,
"Column %s is TimeSecVector but declared type is %s", vector.getName(), type.getDisplayName()); Type guard
boolean isCompatiblePrestoType(ValueVector v, Type t) {
if (v instanceof TimeSecVector) {
return t instanceof TimeType;
}
return true;
} Try / catch
try {
blockBuilder.assignBlockFromTimeSecVector(timeSecVector, type, builder, 0, n);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("must be a TimeType")) {
throw new SchemaMismatchException(vector.getName(), type, "TIME", e);
}
throw e;
} Prevention
- Map Arrow time columns to Presto TIME, not BIGINT epoch seconds
- Validate that time precision (sec/milli/micro) differences don't change the target type
- Run a schema compatibility check when either side upgrades
When it happens
Trigger: assignBlockFromValueVector dispatches a TimeSecVector while the mapped Type resolved to something other than TimeType (e.g. BIGINT, TIME with wrong precision wrapper, or TIMESTAMP) due to a bad mapping.
Common situations: Time columns mapped to bigint epoch-seconds in the catalog; metadata drift after schema changes; custom conversion code passing the wrong Type instance.
Related errors
- Type must be a DecimalType for DecimalVector
- Expected TimestampType but got {type.getClass().getName()}
- Expected VarcharType but got {type.getClass().getName()}
- Expected DateType but got {type.getClass().getName()}
- Unsupported FieldVector type: {fieldVector.getClass()}
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/d4b942d8010d4008.
Report an issue: GitHub.