{"record":{"id":"2a794e6881b3fc98","repo":"apache/seatunnel","slug":"map-type-requires-map-value-got-value-getclass","errorCode":null,"errorMessage":"Map type requires Map value, got: ${value.getClass()}","messagePattern":"Map type requires Map value, got: (.+?)","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-lance/src/main/java/org/apache/seatunnel/connectors/seatunnel/lance/utils/FragmentConverter.java","lineNumber":139,"sourceCode":"        Field elementField = children.get(0);\n        ArrowType elementType = elementField.getType();\n\n        for (Object element : listValue) {\n            writeListElement(writer, elementType, element, allocator);\n        }\n\n        writer.setValueCount(listValue.size());\n        writer.endList();\n    }\n\n    private static void writeMapToVector(\n            MapVector mapVector,\n            Field field,\n            Object value,\n            int rowIndex,\n            BufferAllocator allocator) {\n        if (!(value instanceof java.util.Map)) {\n            throw new IllegalArgumentException(\n                    \"Map type requires Map value, got: \" + value.getClass());\n        }\n\n        UnionMapWriter writer = mapVector.getWriter();\n        writer.setPosition(rowIndex);\n        writer.startMap();\n\n        java.util.Map<?, ?> mapValue = (java.util.Map<?, ?>) value;\n        List<Field> children = field.getChildren();\n        if (children.size() < 2) {\n            throw new IllegalArgumentException(\"Map field must have key and value child fields\");\n        }\n        Field keyField = children.get(0);\n        Field valueField = children.get(1);\n        ArrowType keyType = keyField.getType();\n        ArrowType valueType = valueField.getType();\n\n        for (java.util.Map.Entry<?, ?> entry : mapValue.entrySet()) {","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-lance/src/main/java/org/apache/seatunnel/connectors/seatunnel/lance/utils/FragmentConverter.java#L121-L157","documentation":"FragmentConverter.writeMapToVector throws this IllegalArgumentException when writing a SeaTunnel MAP column into an Arrow MapVector but the runtime value is not a java.util.Map. The converter requires an exact Map instance to iterate key/value pairs; anything else (String, List, POJO) cannot be written as map entries. It is a data/type contract violation between the SeaTunnel row and the Lance/Arrow schema.","triggerScenarios":"setVectorValue dispatches a row field whose SeaTunnel type is MAP_ARRAY/MAP to writeMapToVector, but the Object value at rowIndex is not a java.util.Map (e.g. it is a String, List, or null-wrapped wrapper).","commonSituations":"Custom source connectors emitting raw JSON strings for map columns; data read from formats that deserialize maps into LinkedHashMap alternatives or Lists of pairs; upstream transforms producing wrong column types; schema mismatch after table definition changes.","solutions":["Fix the upstream source/transform so the MAP column carries an actual java.util.Map value","Cast or convert the value (e.g. parse JSON string to Map) before writing","Verify the SeaTunnel catalog schema declares the column as MAP and matches the data","Add a pre-write type check/logging to identify which column and row carries the bad value"],"exampleFix":"// before\nObject value = row.getField(mapColIndex); // value is a JSON string\nconverter.setVectorValue(mapVector, field, value, i, allocator); // throws\n// after\nObject value = row.getField(mapColIndex);\nif (!(value instanceof java.util.Map) && value instanceof String) {\n    value = new com.fasterxml.jackson.databind.ObjectMapper()\n            .readValue((String) value, java.util.Map.class);\n}\nconverter.setVectorValue(mapVector, field, value, i, allocator);","handlingStrategy":"type-guard","validationCode":"if (!(value instanceof java.util.Map)) {\n    throw new IllegalArgumentException(\"Column '\" + field.getName() + \"' expects a java.util.Map, got: \"\n        + (value == null ? \"null\" : value.getClass().getName()));\n}","typeGuard":"boolean isWritableMap(Object v) {\n    return v instanceof java.util.Map;\n}","tryCatchPattern":"try {\n    converter.setVectorValue(mapVector, field, value, rowIndex, allocator);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Map type requires Map value\")) {\n        LOG.warn(\"Skipping non-map value {} at row {} column {}\", value, rowIndex, field.getName());\n    } else {\n        throw e;\n    }\n}","preventionTips":["Enforce SeaTunnel MAP column types in the source so values are materialized as java.util.Map","Add row-level schema validation before writing to Arrow vectors","Log value classes of MAP columns during connector development","Convert JSON-string map columns to Map in an upstream transform"],"tags":["arrow","map-type","type-mismatch","lance"],"backgroundTag":"type-mismatch","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}