prestodb/presto · error · IllegalArgumentException

Type must be a TimeType for TimemicroVector

Error message

Type must be a TimeType for TimemicroVector

What it means

assignBlockFromTimeMicroVector converts an Arrow TimeMicroVector (microsecond time-of-day values) into a Presto block, and it only knows how to do that when the declared Presto column type is TimeType. If the caller passes any other Type (e.g. TimestampType or BigintType), the mapping is ambiguous or wrong, so the method fails fast with this IllegalArgumentException.

Source

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

        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 {
                long millis = vector.get(i);
                type.writeLong(builder, millis);
            }
        }
    }

    public void assignBlockFromTimeMicroVector(TimeMicroVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)
    {
        if (!(type instanceof TimeType)) {
            throw new IllegalArgumentException("Type must be a TimeType for TimemicroVector");
        }
        for (int i = startIndex; i < endIndex; i++) {
            if (vector.isNull(i)) {
                builder.appendNull();
            }
            else {
                long value = vector.get(i);
                long micro = TimeUnit.MICROSECONDS.toMillis(value);
                type.writeLong(builder, micro);
            }
        }
    }

    public void assignBlockFromTimeStampSecVector(TimeStampSecVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)
    {
        if (!(type instanceof TimestampType)) {
            throw new IllegalArgumentException("Type must be a TimestampType for TimeStampSecVector");
        }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Change the Presto column Type to TimeType so it matches the TimeMicroVector
  2. Fix the dispatch in assignBlockFromValueVector so TimeMicroVector values are paired with the correct column's Type
  3. If the data is really timestamps, have the producer write a TIMESTAMP_MICRO vector instead of TIME_MICRO

Example fix

// before
assignBlockFromTimeMicroVector(timeMicroVector, TimestampType.TIMESTAMP, builder, start, end);
// after
assignBlockFromTimeMicroVector(timeMicroVector, TimeType.TIME, builder, start, end);
Defensive patterns

Strategy: type-guard

Validate before calling

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

Type guard

boolean isTimeColumn(Type type) {
    return type instanceof TimeType;
}

Try / catch

try {
    builder.assignBlockFromTimeMicroVector(vector, type, blockBuilder, start, end);
} catch (IllegalArgumentException e) {
    if (!e.getMessage().contains("TimeType for TimemicroVector")) throw e;
    // fall back: re-map column type or skip column
}

Prevention

When it happens

Trigger: Calling assignBlockFromTimeMicroVector (directly or via assignBlockFromValueVector dispatch) with a Type that is not an instance of TimeType, e.g. a column declared as TIMESTAMP while the Arrow vector holds TIME_MICRO data.

Common situations: Schema drift between the Arrow Flight producer and the Presto table definition: the Arrow source encodes a time-of-day column as TIME_MICRO but the Presto metadata declares it as TIMESTAMP or BIGINT; hand-written dispatch tables passing the wrong Type per column; columns reordered so a TimeMicroVector is paired with another column's type.

Related errors


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