{"record":{"id":"189755d58c3ae341","repo":"apache/seatunnel","slug":"map-as-map-key-is-not-supported","errorCode":null,"errorMessage":"Map as map key is not supported","messagePattern":"Map as map key is not supported","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":47,"sourceCode":"            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) {\n        throw new UnsupportedOperationException(\"Map as map value not yet implemented\");\n    }\n}\n","sourceCodeStart":29,"sourceCodeEnd":56,"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#L29-L56","documentation":"MapTypeWriter.writeToMapKey rejects MAP values used as MAP keys. Arrow map key vectors support only flat, hashable scalar types; a nested map can never be a key. This method throws UnsupportedOperationException unconditionally as a guard.","triggerScenarios":"A SeaTunnel MAP field declared with MAP as its key type (map<map<...>, V>); during entry writing the key dispatch reaches MapTypeWriter.writeToMapKey.","commonSituations":"Deeply nested schema modeling mistakes; programmatic schema generation that accidentally nests maps; porting data from systems that allow struct-like keys.","solutions":["Use a scalar key type (STRING/INT) in the map schema.","Encode a composite key as a canonical string (e.g. JSON or delimited concatenation of the nested map).","Restructure as LIST<STRUCT<key, value>> where the 'key' can itself be a struct.","Add a pre-write schema validation step that asserts map key types are scalar."],"exampleFix":"// before\ncolumns = \"data map<map<string,string>, int>\"\n\n// after: string-encoded key\ncolumns = \"data map<string, int>\"  // key = JSON string of inner map","handlingStrategy":"validation","validationCode":"// Java: assert map key type is not a nested map\nArrowType keyType = mapField.getChildren().get(0).getType();\nif (keyType instanceof ArrowType.Map) {\n    throw new IllegalArgumentException(\"map keys must be scalar, not map\");\n}","typeGuard":"boolean isScalarKey(ArrowType t) {\n    return !(t instanceof ArrowType.Map) && !(t instanceof ArrowType.List);\n}","tryCatchPattern":null,"preventionTips":["Treat map keys as flat identifiers only (string/int)","Hash or serialize nested key structures to a canonical string","Add schema validation before job submission"],"tags":["lance","arrow","map-key","nested-type","sink"],"backgroundTag":"unsupported-operation","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"}