{"record":{"id":"4de5b3d3a1e60045","repo":"apache/seatunnel","slug":"map-type-requires-key-and-value-types","errorCode":null,"errorMessage":"MAP type requires key and value types","messagePattern":"MAP type requires key and value types","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveTypeConvertor.java","lineNumber":143,"sourceCode":"                            (org.apache.seatunnel.api.table.type.ArrayType<?, ?>) seaTunnelType;\n                    org.apache.seatunnel.api.table.type.SeaTunnelDataType<?> elementType =\n                            arrayType.getElementType();\n                    if (elementType == null) {\n                        throw new UnsupportedOperationException(\"ARRAY type requires element type\");\n                    }\n                    return \"array<\" + seatunnelToHiveType(elementType) + \">\";\n                }\n                throw new UnsupportedOperationException(\"ARRAY type requires element type\");\n            case MAP:\n                if (seaTunnelType instanceof org.apache.seatunnel.api.table.type.MapType) {\n                    org.apache.seatunnel.api.table.type.MapType<?, ?> mapType =\n                            (org.apache.seatunnel.api.table.type.MapType<?, ?>) seaTunnelType;\n                    org.apache.seatunnel.api.table.type.SeaTunnelDataType<?> keyType =\n                            mapType.getKeyType();\n                    org.apache.seatunnel.api.table.type.SeaTunnelDataType<?> valueType =\n                            mapType.getValueType();\n                    if (keyType == null || valueType == null) {\n                        throw new UnsupportedOperationException(\n                                \"MAP type requires key and value types\");\n                    }\n                    return \"map<\"\n                            + seatunnelToHiveType(keyType)\n                            + \",\"\n                            + seatunnelToHiveType(valueType)\n                            + \">\";\n                }\n                throw new UnsupportedOperationException(\"MAP type requires key and value types\");\n            case NULL:\n                throw new UnsupportedOperationException(\"Orc does not support NULL type\");\n            default:\n                throw new UnsupportedOperationException(\n                        String.format(\n                                \"Unsupported type conversion from %s to Hive ORC type\",\n                                seaTunnelType.getSqlType()));\n        }\n    }","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveTypeConvertor.java#L125-L161","documentation":"When converting a MAP type to a Hive map type, both the key type and value type from MapType.getKeyType()/getValueType() must be non-null. A null key or value type cannot be rendered as `map<k,v>` so the converter throws UnsupportedOperationException.","triggerScenarios":"Calling seatunnelToHiveType on a MapType whose getKeyType() or getValueType() returns null — possible only with a manually built or corrupted MapType, since the API constructor normally enforces non-null types.","commonSituations":"Hand-constructed MapType with a null value type; schema deserialization across incompatible SeaTunnel API versions losing type info; reflection-based schema building that skipped nested types.","solutions":["Rebuild the MapType with explicit non-null key and value types, e.g. new MapType<>(BasicType.STRING_TYPE, BasicType.LONG_TYPE).","Validate keyType != null && valueType != null before conversion.","Re-derive the schema from the source if it was deserialized from an incompatible version."],"exampleFix":"// before\nMapType<?, ?> bad = new MapType<>(BasicType.STRING_TYPE, null);\n// after\nMapType<String, Long> ok = new MapType<>(BasicType.STRING_TYPE, BasicType.LONG_TYPE);","handlingStrategy":"validation","validationCode":"if (mapType.getKeyType() == null || mapType.getValueType() == null) {\n    throw new IllegalArgumentException(\"MapType must have non-null key and value types\");\n}","typeGuard":"static boolean hasKeyAndValueTypes(MapType<?, ?> m) {\n    return m != null && m.getKeyType() != null && m.getValueType() != null;\n}","tryCatchPattern":"try {\n    String hiveType = HiveTypeConvertor.seatunnelToHiveType(mapType);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().contains(\"MAP type requires\")) {\n        // rebuild the MapType with concrete key/value types\n    }\n    throw e;\n}","preventionTips":["Construct MapType with explicit BasicType/row types for both key and value.","Never build MapType with null type arguments even as placeholders.","Round-trip test deserialized nested schemas."],"tags":["hive","type-conversion","map-type"],"backgroundTag":"null-argument","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}