{"record":{"id":"a551671b30d57dc1","repo":"prestodb/presto","slug":"type-must-be-an-arraytype-for-listvector","errorCode":null,"errorMessage":"Type must be an ArrayType for ListVector","messagePattern":"Type must be an ArrayType for ListVector","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-common-arrow/src/main/java/com/facebook/plugin/arrow/ArrowBlockBuilder.java","lineNumber":659,"sourceCode":"        if (!(type instanceof TimestampType)) {\n            throw new IllegalArgumentException(\"Type must be a TimestampType for TimeStampMilliTZVector\");\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 assignBlockFromListVector(ListVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)\n    {\n        if (!(type instanceof ArrayType)) {\n            throw new IllegalArgumentException(\"Type must be an ArrayType for ListVector\");\n        }\n\n        ArrayType arrayType = (ArrayType) type;\n        Type elementType = arrayType.getElementType();\n\n        for (int i = startIndex; i < endIndex; i++) {\n            if (vector.isNull(i)) {\n                builder.appendNull();\n            }\n            else {\n                BlockBuilder elementBuilder = builder.beginBlockEntry();\n                assignBlockFromValueVector(\n                        vector.getDataVector(), elementType, elementBuilder, vector.getElementStartIndex(i), vector.getElementEndIndex(i));\n                builder.closeEntry();\n            }\n        }\n    }\n","sourceCodeStart":641,"sourceCodeEnd":677,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common-arrow/src/main/java/com/facebook/plugin/arrow/ArrowBlockBuilder.java#L641-L677","documentation":"assignBlockFromListVector converts an Arrow ListVector into a Presto array block. It needs the Presto Type to be ArrayType so it can extract the element type for recursive conversion; if the Type is anything else (scalar, RowType, MapType), the conversion cannot proceed and this IllegalArgumentException is thrown.","triggerScenarios":"Calling assignBlockFromListVector (directly or via assignBlockFromValueVector) with a non-ArrayType, e.g. a MAP or ROW declared column receiving a ListVector, or a VARCHAR column whose values were encoded as lists.","commonSituations":"Arrow schema declares a list column but the Presto table was created with the wrong column type (e.g. json or row instead of array); nested-type dispatch bugs where LIST vectors get paired with the parent row's type.","solutions":["Declare the Presto column as an array of the matching element type (ArrayType)","Fix the Type passed to this method in the dispatch path so the list column gets its own ArrayType","Check the Arrow field vs Presto column alignment (names/indices) that feeds assignBlockFromValueVector"],"exampleFix":"// before\nassignBlockFromListVector(listVector, MapType, builder, start, end);\n// after\nassignBlockFromListVector(listVector, ArrayType.from(elementType), builder, start, end);","handlingStrategy":"type-guard","validationCode":"if (!(columnType instanceof ArrayType)) {\n    throw new IllegalStateException(\"Column '\" + name + \"' must be ArrayType to receive ListVector, got \" + columnType);\n}","typeGuard":"boolean isArrayColumn(Type type) {\n    return type instanceof ArrayType;\n}","tryCatchPattern":"try {\n    builder.assignBlockFromListVector(vector, type, blockBuilder, start, end);\n} catch (IllegalArgumentException e) {\n    if (!e.getMessage().contains(\"ArrayType for ListVector\")) throw e;\n    // fall back to a type-coercing reader or error out with context\n}","preventionTips":["Map Arrow LIST fields to array(...) Presto types programmatically","Check element types match (ArrayType.getElementType vs Arrow child field) too","Cover nested list types in connector schema tests"],"tags":["arrow","type-mismatch","array","list"],"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"}