{"record":{"id":"d4b942d8010d4008","repo":"prestodb/presto","slug":"type-must-be-a-timetype-for-timesecvector","errorCode":null,"errorMessage":"Type must be a TimeType for TimeSecVector","messagePattern":"Type must be a TimeType for TimeSecVector","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-common-arrow/src/main/java/com/facebook/plugin/arrow/ArrowBlockBuilder.java","lineNumber":544,"sourceCode":"            throw new IllegalArgumentException(\"Expected DateType 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                DateType dateType = (DateType) type;\n                long days = TimeUnit.MILLISECONDS.toDays(vector.get(i));\n                dateType.writeLong(builder, days);\n            }\n        }\n    }\n\n    public void assignBlockFromTimeSecVector(TimeSecVector 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 TimeSecVector\");\n        }\n\n        for (int i = startIndex; i < endIndex; i++) {\n            if (vector.isNull(i)) {\n                builder.appendNull();\n            }\n            else {\n                int value = vector.get(i);\n                long millis = TimeUnit.SECONDS.toMillis(value);\n                type.writeLong(builder, millis);\n            }\n        }\n    }\n\n    public void assignBlockFromTimeMilliVector(TimeMilliVector 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 TimeSecVector\");","sourceCodeStart":526,"sourceCodeEnd":562,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common-arrow/src/main/java/com/facebook/plugin/arrow/ArrowBlockBuilder.java#L526-L562","documentation":"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').","triggerScenarios":"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.","commonSituations":"Time columns mapped to bigint epoch-seconds in the catalog; metadata drift after schema changes; custom conversion code passing the wrong Type instance.","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"],"exampleFix":"// before\nType type = BIGINT; // wrong for TimeSecVector\n// after\nType type = TimeType.TIME;","handlingStrategy":"validation","validationCode":"checkArgument(type instanceof TimeType,\n    \"Column %s is TimeSecVector but declared type is %s\", vector.getName(), type.getDisplayName());","typeGuard":"boolean isCompatiblePrestoType(ValueVector v, Type t) {\n    if (v instanceof TimeSecVector) {\n        return t instanceof TimeType;\n    }\n    return true;\n}","tryCatchPattern":"try {\n    blockBuilder.assignBlockFromTimeSecVector(timeSecVector, type, builder, 0, n);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"must be a TimeType\")) {\n        throw new SchemaMismatchException(vector.getName(), type, \"TIME\", e);\n    }\n    throw e;\n}","preventionTips":["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"],"tags":["arrow","java","type-mismatch","time","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"}