{"record":{"id":"beb8367a8d0b307e","repo":"prestodb/presto","slug":"expected-timestamptype-but-got-type-getclass-ge","errorCode":null,"errorMessage":"Expected TimestampType but got {type.getClass().getName()}","messagePattern":"Expected TimestampType but got (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-common-arrow/src/main/java/com/facebook/plugin/arrow/ArrowBlockBuilder.java","lineNumber":417,"sourceCode":"                else {\n                    Slice slice = Decimals.encodeScaledValue(decimal);\n                    decimalType.writeSlice(builder, slice, 0, slice.length());\n                }\n            }\n        }\n    }\n\n    public void assignBlockFromNullVector(NullVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)\n    {\n        for (int i = startIndex; i < endIndex; i++) {\n            builder.appendNull();\n        }\n    }\n\n    public void assignBlockFromTimeStampMicroVector(TimeStampMicroVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)\n    {\n        if (!(type instanceof TimestampType)) {\n            throw new IllegalArgumentException(\"Expected TimestampType but got \" + type.getClass().getName());\n        }\n\n        for (int i = startIndex; i < endIndex; i++) {\n            if (vector.isNull(i)) {\n                builder.appendNull();\n            }\n            else {\n                long micros = vector.get(i);\n                long millis = TimeUnit.MICROSECONDS.toMillis(micros);\n                type.writeLong(builder, millis);\n            }\n        }\n    }\n\n    public void assignBlockFromTimeStampMilliVector(TimeStampMilliVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)\n    {\n        if (!(type instanceof TimestampType)) {\n            throw new IllegalArgumentException(\"Expected TimestampType but got \" + type.getClass().getName());","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common-arrow/src/main/java/com/facebook/plugin/arrow/ArrowBlockBuilder.java#L399-L435","documentation":"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.","triggerScenarios":"assignBlockFromValueVector dispatches a TimeStampMicroVector but the mapped Type resolved to something else (e.g. BIGINT, TimestampWithTimeZone, or DATE) because of an incorrect type mapping.","commonSituations":"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.","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"],"exampleFix":"// before\nType type = BIGINT; // mismatch for TimeStampMicroVector\n// after\nType type = TimestampType.TIMESTAMP;","handlingStrategy":"validation","validationCode":"checkArgument(type instanceof TimestampType,\n    \"Column %s is TimeStampMicroVector but declared type is %s\", vector.getName(), type.getDisplayName());","typeGuard":"boolean isCompatiblePrestoType(ValueVector v, Type t) {\n    if (v instanceof TimeStampMicroVector) {\n        return t instanceof TimestampType;\n    }\n    return true;\n}","tryCatchPattern":"try {\n    blockBuilder.assignBlockFromTimeStampMicroVector(tsMicroVector, type, builder, 0, n);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Expected TimestampType\")) {\n        throw new SchemaMismatchException(vector.getName(), type, \"TIMESTAMP\", e);\n    }\n    throw e;\n}","preventionTips":["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"],"tags":["arrow","java","type-mismatch","timestamp","illegal-argument"],"backgroundTag":"arrow-presto-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"}