{"record":{"id":"7b694f756371b85a","repo":"apache/seatunnel","slug":"map-type-should-be-handled-via-fragmentconverter-w","errorCode":null,"errorMessage":"Map type should be handled via FragmentConverter.writeMapToVector","messagePattern":"Map type should be handled via FragmentConverter\\.writeMapToVector","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-lance/src/main/java/org/apache/seatunnel/connectors/seatunnel/lance/sink/writers/MapTypeWriter.java","lineNumber":34,"sourceCode":" */\n\npackage org.apache.seatunnel.connectors.seatunnel.lance.sink.writers;\n\nimport org.apache.arrow.memory.BufferAllocator;\nimport org.apache.arrow.vector.FieldVector;\nimport org.apache.arrow.vector.complex.impl.UnionListWriter;\nimport org.apache.arrow.vector.complex.impl.UnionMapWriter;\nimport org.apache.arrow.vector.types.pojo.ArrowType;\n\npublic class MapTypeWriter extends BaseTypeWriter {\n    @Override\n    public void writeToVector(\n            FieldVector vector,\n            ArrowType arrowType,\n            Object value,\n            int rowIndex,\n            BufferAllocator allocator) {\n        throw new UnsupportedOperationException(\n                \"Map type should be handled via FragmentConverter.writeMapToVector\");\n    }\n\n    @Override\n    public void writeToListWriter(\n            UnionListWriter writer, ArrowType arrowType, Object value, BufferAllocator allocator) {\n        throw new UnsupportedOperationException(\"Map in list writing not yet implemented\");\n    }\n\n    @Override\n    public void writeToMapKey(\n            UnionMapWriter writer, ArrowType arrowType, Object value, BufferAllocator allocator) {\n        throw new UnsupportedOperationException(\"Map as map key is not supported\");\n    }\n\n    @Override\n    public void writeToMapValue(\n            UnionMapWriter writer, ArrowType arrowType, Object value, BufferAllocator allocator) {","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-lance/src/main/java/org/apache/seatunnel/connectors/seatunnel/lance/sink/writers/MapTypeWriter.java#L16-L52","documentation":"MapTypeWriter.writeToVector is deliberately unusable: MAP-typed columns in the Lance sink are not written through the generic per-column TypeWriter dispatch, but through the dedicated FragmentConverter.writeMapToVector code path. Hitting this throw means a map value was routed to the wrong writer path — an internal dispatch bug rather than a user data problem.","triggerScenarios":"FragmentConverter.setVectorValue (or a custom caller) calls TypeWriterFactory.getWriter for an ArrowType.Map field and invokes writeToVector instead of special-casing it with writeMapToVector.","commonSituations":"Any Lance sink write containing a MAP column where the converter's type dispatch fails to recognize the Map arrow type first; modifications to FragmentConverter that bypass the map branch.","solutions":["Inspect FragmentConverter.setVectorValue and ensure ArrowType.Map is checked BEFORE the generic TypeWriterFactory.getWriter dispatch so writeMapToVector is used.","If you added a new write path, route Map-typed fields explicitly to FragmentConverter.writeMapToVector.","File/verify a connector bug with the schema (field type map<...>) that triggered the wrong dispatch.","As a workaround, convert the MAP column to a JSON string in the pipeline until the dispatch is fixed."],"exampleFix":"// before (generic dispatch)\nTypeWriter writer = TypeWriterFactory.getWriter(field.getType());\nwriter.writeToVector(vector, field.getType(), value, rowIndex, allocator);\n\n// after (special-case map)\nif (field.getType() instanceof ArrowType.Map) {\n    FragmentConverter.writeMapToVector(mapVector, field, value, rowIndex, allocator);\n} else {\n    TypeWriterFactory.getWriter(field.getType()).writeToVector(vector, field.getType(), value, rowIndex, allocator);\n}","handlingStrategy":"try-catch","validationCode":"// Java: ensure map fields are routed to the dedicated path\nboolean mapHandledSpecially = field.getType() instanceof ArrowType.Map;\nif (!mapHandledSpecially) { /* safe to use TypeWriterFactory */ }","typeGuard":null,"tryCatchPattern":"try {\n    writer.writeToVector(vector, arrowType, value, rowIndex, allocator);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().contains(\"FragmentConverter.writeMapToVector\")) {\n        FragmentConverter.writeMapToVector((MapVector) vector, field, value, rowIndex, allocator);\n    } else { throw e; }\n}","preventionTips":["Never call the generic TypeWriter dispatch for ArrowType.Map fields","Keep the map special-case first in any dispatch code you add to FragmentConverter","Add a unit test covering a map column through setVectorValue"],"tags":["lance","arrow","map-type","internal-dispatch","sink"],"backgroundTag":"internal-invariant-violation","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"}