apache/seatunnel · error · UnsupportedOperationException
MAP type requires key and value types
Error message
MAP type requires key and value types
What it means
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.
Source
Thrown at seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveTypeConvertor.java:143
(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)
+ ","
+ seatunnelToHiveType(valueType)
+ ">";
}
throw new UnsupportedOperationException("MAP type requires key and value types");
case NULL:
throw new UnsupportedOperationException("Orc does not support NULL type");
default:
throw new UnsupportedOperationException(
String.format(
"Unsupported type conversion from %s to Hive ORC type",
seaTunnelType.getSqlType()));
}
}View on GitHub (pinned to cf67b549a7)
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.
Example fix
// before MapType<?, ?> bad = new MapType<>(BasicType.STRING_TYPE, null); // after MapType<String, Long> ok = new MapType<>(BasicType.STRING_TYPE, BasicType.LONG_TYPE);
Defensive patterns
Strategy: validation
Validate before calling
if (mapType.getKeyType() == null || mapType.getValueType() == null) {
throw new IllegalArgumentException("MapType must have non-null key and value types");
} Type guard
static boolean hasKeyAndValueTypes(MapType<?, ?> m) {
return m != null && m.getKeyType() != null && m.getValueType() != null;
} Try / catch
try {
String hiveType = HiveTypeConvertor.seatunnelToHiveType(mapType);
} catch (UnsupportedOperationException e) {
if (e.getMessage().contains("MAP type requires")) {
// rebuild the MapType with concrete key/value types
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- ROW type requires non-empty field names and types with equal
- ROW type requires non-empty field names and types
- ARRAY type requires element type
- Orc does not support NULL type
- Unsupported type conversion from %s to Hive ORC type
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/4de5b3d3a1e60045.
Report an issue: GitHub.