prestodb/presto · error · IllegalArgumentException

Type must be a TimestampType for TimeStampSecVector

Error message

Type must be a TimestampType for TimeStampSecVector

What it means

assignBlockFromTimeStampSecVector converts an Arrow TimeStampSecVector (seconds-since-epoch values) into a Presto block, which requires the Presto column Type to be TimestampType. A non-TimestampType cannot express the values correctly, so the method throws this IllegalArgumentException before writing any rows.

Source

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

        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");
        }

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

    public void assignCharTypeBlockFromVarcharVector(VarCharVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)
    {
        for (int i = startIndex; i < endIndex; i++) {
            if (vector.isNull(i)) {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Declare the Presto column as TimestampType to match the TimeStampSecVector
  2. Correct the type passed through assignBlockFromValueVector's dispatch for this column
  3. Convert the vector to the expected minor type on the producer side (or cast in Presto)

Example fix

// before
assignBlockFromTimeStampSecVector(secVector, BigintType.BIGINT, builder, start, end);
// after
assignBlockFromTimeStampSecVector(secVector, TimestampType.TIMESTAMP, builder, start, end);
Defensive patterns

Strategy: type-guard

Validate before calling

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

Type guard

boolean isTimestampColumn(Type type) {
    return type instanceof TimestampType;
}

Try / catch

try {
    builder.assignBlockFromTimeStampSecVector(vector, type, blockBuilder, start, end);
} catch (IllegalArgumentException e) {
    if (!e.getMessage().contains("TimestampType for TimeStampSecVector")) throw e;
    // correct the type or re-dispatch
}

Prevention

When it happens

Trigger: Calling assignBlockFromTimeStampSecVector (directly or via assignBlockFromValueVector) with a Type that is not TimestampType, e.g. a BIGINT or DATE column type paired with a TIMESTAMP_SEC vector.

Common situations: Arrow source emits epoch-seconds while the Presto column is declared as BIGINT (raw epoch) or DATE; type metadata built from a stale/different schema than the vectors; column order mismatch in a dispatch switch.

Related errors


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