{"record":{"id":"98bfc4a2a9d08c09","repo":"prestodb/presto","slug":"expected-datetype-but-got-type-getclass-getname","errorCode":null,"errorMessage":"Expected DateType but got {type.getClass().getName()}","messagePattern":"Expected DateType but got (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-common-arrow/src/main/java/com/facebook/plugin/arrow/ArrowBlockBuilder.java","lineNumber":510,"sourceCode":"\n        for (int i = startIndex; i < endIndex; i++) {\n            if (vector.isNull(i)) {\n                builder.appendNull();\n            }\n            else {\n                // Directly create a Slice from the raw byte array\n                byte[] rawBytes = vector.get(i);\n                Slice slice = Slices.wrappedBuffer(rawBytes);\n                // Write the Slice directly to the builder\n                type.writeSlice(builder, slice);\n            }\n        }\n    }\n\n    public void assignBlockFromDateDayVector(DateDayVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)\n    {\n        if (!(type instanceof DateType)) {\n            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                type.writeLong(builder, vector.get(i));\n            }\n        }\n    }\n\n    public void assignBlockFromDateMilliVector(DateMilliVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)\n    {\n        if (!(type instanceof DateType)) {\n            throw new IllegalArgumentException(\"Expected DateType but got \" + type.getClass().getName());\n        }\n","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common-arrow/src/main/java/com/facebook/plugin/arrow/ArrowBlockBuilder.java#L492-L528","documentation":"assignBlockFromDateDayVector expects the paired Presto Type to be DateType because it converts Arrow day-granularity dates (days since epoch) into Presto date blocks. If type is not a DateType it throws IllegalArgumentException('Expected DateType but got <class>').","triggerScenarios":"assignBlockFromValueVector dispatches a DateDayVector while the mapped Type is not DateType — e.g. it was mapped to DATE's underlying integer type, TIMESTAMP, or BIGINT.","commonSituations":"Date columns mapped to integer/timestamp in the connector catalog; schema metadata out of sync with the Arrow data; custom code passing epoch-day values as bigint with a BIGINT type.","solutions":["Correct the mapping so DateDay columns map to Presto DateType","Refresh the connector's schema/table metadata","Cast the column to date on the producer side if the declared type differs intentionally","Assert type instanceof DateType before invoking the assign method in custom code"],"exampleFix":"// before\nType type = BIGINT; // wrong for DateDayVector\n// after\nType type = DateType.DATE;","handlingStrategy":"validation","validationCode":"checkArgument(type instanceof DateType,\n    \"Column %s is DateDayVector but declared type is %s\", vector.getName(), type.getDisplayName());","typeGuard":"boolean isCompatiblePrestoType(ValueVector v, Type t) {\n    if (v instanceof DateDayVector) {\n        return t instanceof DateType;\n    }\n    return true;\n}","tryCatchPattern":"try {\n    blockBuilder.assignBlockFromDateDayVector(dateDayVector, type, builder, 0, n);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Expected DateType\")) {\n        throw new SchemaMismatchException(vector.getName(), type, \"DATE\", e);\n    }\n    throw e;\n}","preventionTips":["Map Arrow date columns to Presto DATE, not BIGINT epoch days","Validate the schema mapping when the producer switches between date and timestamp types","Add a schema-compat check to the ingestion pipeline"],"tags":["arrow","java","type-mismatch","date","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"}