apache/seatunnel · error · UnsupportedOperationException

ARRAY type requires element type

Error message

ARRAY type requires element type

What it means

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.

Source

Thrown at seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveTypeConvertor.java:129

                            sb.append(',');
                        }
                        sb.append(fieldNames[i])
                                .append(':')
                                .append(seatunnelToHiveType(fieldTypes[i]));
                    }
                    sb.append('>');
                    return sb.toString();
                }
                throw new UnsupportedOperationException(
                        "ROW type requires non-empty field names and types");
            case ARRAY:
                if (seaTunnelType instanceof org.apache.seatunnel.api.table.type.ArrayType) {
                    org.apache.seatunnel.api.table.type.ArrayType<?, ?> arrayType =
                            (org.apache.seatunnel.api.table.type.ArrayType<?, ?>) seaTunnelType;
                    org.apache.seatunnel.api.table.type.SeaTunnelDataType<?> elementType =
                            arrayType.getElementType();
                    if (elementType == null) {
                        throw new UnsupportedOperationException("ARRAY type requires element type");
                    }
                    return "array<" + seatunnelToHiveType(elementType) + ">";
                }
                throw new UnsupportedOperationException("ARRAY type requires element type");
            case MAP:
                if (seaTunnelType instanceof org.apache.seatunnel.api.table.type.MapType) {
                    org.apache.seatunnel.api.table.type.MapType<?, ?> mapType =
                            (org.apache.seatunnel.api.table.type.MapType<?, ?>) seaTunnelType;
                    org.apache.seatunnel.api.table.type.SeaTunnelDataType<?> keyType =
                            mapType.getKeyType();
                    org.apache.seatunnel.api.table.type.SeaTunnelDataType<?> valueType =
                            mapType.getValueType();
                    if (keyType == null || valueType == null) {
                        throw new UnsupportedOperationException(
                                "MAP type requires key and value types");
                    }
                    return "map<"
                            + seatunnelToHiveType(keyType)

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Reconstruct the ArrayType with a valid non-null element type, e.g. ArrayType.STRING_ARRAY_TYPE or new ArrayType<>(elementClass, elementType).
  2. Validate elementType != null before invoking the converter.
  3. If the type came from a serialized catalog payload, re-derive the schema from the source instead of trusting the deserialized type.

Example fix

// before
ArrayType<?, ?> bad = new ArrayType<>(String.class, null);
// after
ArrayType<String[], String> ok = ArrayType.STRING_ARRAY_TYPE;
Defensive patterns

Strategy: validation

Validate before calling

if (arrayType.getElementType() == null) {
    throw new IllegalArgumentException("ArrayType must be built with a non-null element type");
}

Type guard

static boolean hasElementType(ArrayType<?, ?> a) {
    return a != null && a.getElementType() != null;
}

Try / catch

try {
    String hiveType = HiveTypeConvertor.seatunnelToHiveType(arrayType);
} catch (UnsupportedOperationException e) {
    if (e.getMessage().contains("ARRAY type requires")) {
        // rebuild the ArrayType with a concrete element type
    }
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: Hand-built ArrayType via reflection or serialization where the element type field was lost; deserialization of a schema across incompatible SeaTunnel API versions.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/cfe61a21fa1c7604. Report an issue: GitHub.