{"record":{"id":"cfe61a21fa1c7604","repo":"apache/seatunnel","slug":"array-type-requires-element-type","errorCode":null,"errorMessage":"ARRAY type requires element type","messagePattern":"ARRAY type requires element type","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":129,"sourceCode":"                            sb.append(',');\n                        }\n                        sb.append(fieldNames[i])\n                                .append(':')\n                                .append(seatunnelToHiveType(fieldTypes[i]));\n                    }\n                    sb.append('>');\n                    return sb.toString();\n                }\n                throw new UnsupportedOperationException(\n                        \"ROW type requires non-empty field names and types\");\n            case ARRAY:\n                if (seaTunnelType instanceof org.apache.seatunnel.api.table.type.ArrayType) {\n                    org.apache.seatunnel.api.table.type.ArrayType<?, ?> arrayType =\n                            (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)","sourceCodeStart":111,"sourceCodeEnd":147,"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#L111-L147","documentation":"When converting an ARRAY type to a Hive array type, the element type obtained from ArrayType.getElementType() must be non-null. A null element type cannot be rendered as `array<...>` so the converter throws UnsupportedOperationException.","triggerScenarios":"Calling seatunnelToHiveType on an ArrayType whose getElementType() returns null — only possible with a manually constructed or corrupted ArrayType instance, since the API normally enforces a non-null element type.","commonSituations":"Hand-built ArrayType via reflection or serialization where the element type field was lost; deserialization of a schema across incompatible SeaTunnel API versions.","solutions":["Reconstruct the ArrayType with a valid non-null element type, e.g. ArrayType.STRING_ARRAY_TYPE or new ArrayType<>(elementClass, elementType).","Validate elementType != null before invoking the converter.","If the type came from a serialized catalog payload, re-derive the schema from the source instead of trusting the deserialized type."],"exampleFix":"// before\nArrayType<?, ?> bad = new ArrayType<>(String.class, null);\n// after\nArrayType<String[], String> ok = ArrayType.STRING_ARRAY_TYPE;","handlingStrategy":"validation","validationCode":"if (arrayType.getElementType() == null) {\n    throw new IllegalArgumentException(\"ArrayType must be built with a non-null element type\");\n}","typeGuard":"static boolean hasElementType(ArrayType<?, ?> a) {\n    return a != null && a.getElementType() != null;\n}","tryCatchPattern":"try {\n    String hiveType = HiveTypeConvertor.seatunnelToHiveType(arrayType);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().contains(\"ARRAY type requires\")) {\n        // rebuild the ArrayType with a concrete element type\n    }\n    throw e;\n}","preventionTips":["Prefer predefined constants (e.g. ArrayType.STRING_ARRAY_TYPE) over manual construction.","Never pass null as the element type to the ArrayType constructor.","Round-trip test serialized schemas to catch lost element types."],"tags":["hive","type-conversion","array-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"}