{"record":{"id":"f663cf1d283f3982","repo":"prestodb/presto","slug":"type-must-be-a-timetype-for-timemicrovector","errorCode":null,"errorMessage":"Type must be a TimeType for TimemicroVector","messagePattern":"Type must be a TimeType for TimemicroVector","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-common-arrow/src/main/java/com/facebook/plugin/arrow/ArrowBlockBuilder.java","lineNumber":579,"sourceCode":"        if (!(type instanceof TimeType)) {\n            throw new IllegalArgumentException(\"Type must be a TimeType for TimeSecVector\");\n        }\n\n        for (int i = startIndex; i < endIndex; i++) {\n            if (vector.isNull(i)) {\n                builder.appendNull();\n            }\n            else {\n                long millis = vector.get(i);\n                type.writeLong(builder, millis);\n            }\n        }\n    }\n\n    public void assignBlockFromTimeMicroVector(TimeMicroVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)\n    {\n        if (!(type instanceof TimeType)) {\n            throw new IllegalArgumentException(\"Type must be a TimeType for TimemicroVector\");\n        }\n        for (int i = startIndex; i < endIndex; i++) {\n            if (vector.isNull(i)) {\n                builder.appendNull();\n            }\n            else {\n                long value = vector.get(i);\n                long micro = TimeUnit.MICROSECONDS.toMillis(value);\n                type.writeLong(builder, micro);\n            }\n        }\n    }\n\n    public void assignBlockFromTimeStampSecVector(TimeStampSecVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)\n    {\n        if (!(type instanceof TimestampType)) {\n            throw new IllegalArgumentException(\"Type must be a TimestampType for TimeStampSecVector\");\n        }","sourceCodeStart":561,"sourceCodeEnd":597,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common-arrow/src/main/java/com/facebook/plugin/arrow/ArrowBlockBuilder.java#L561-L597","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Change the Presto column Type to TimeType so it matches the TimeMicroVector","Fix the dispatch in assignBlockFromValueVector so TimeMicroVector values are paired with the correct column's Type","If the data is really timestamps, have the producer write a TIMESTAMP_MICRO vector instead of TIME_MICRO"],"exampleFix":"// before\nassignBlockFromTimeMicroVector(timeMicroVector, TimestampType.TIMESTAMP, builder, start, end);\n// after\nassignBlockFromTimeMicroVector(timeMicroVector, TimeType.TIME, builder, start, end);","handlingStrategy":"type-guard","validationCode":"if (!(columnType instanceof TimeType)) {\n    throw new IllegalStateException(\"Column '\" + name + \"' must be TimeType to receive TimeMicroVector, got \" + columnType);\n}","typeGuard":"boolean isTimeColumn(Type type) {\n    return type instanceof TimeType;\n}","tryCatchPattern":"try {\n    builder.assignBlockFromTimeMicroVector(vector, type, blockBuilder, start, end);\n} catch (IllegalArgumentException e) {\n    if (!e.getMessage().contains(\"TimeType for TimemicroVector\")) throw e;\n    // fall back: re-map column type or skip column\n}","preventionTips":["Derive the Presto Type from the Arrow field type instead of hardcoding it","Keep a single source of truth for the Arrow-to-Presto schema mapping","Add unit tests pairing every Arrow vector type with its expected Presto Type"],"tags":["arrow","type-mismatch","presto","java"],"backgroundTag":"arrow-vector-type-mismatch","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}