apache/seatunnel · error · UnsupportedOperationException

Unsupported convert %s to Map, typeDefine: %s

Error message

Unsupported convert %s to Map, typeDefine: %s

What it means

The default convertMap implementation accepts only java.util.Map instances; anything else triggers this UnsupportedOperationException. The typeDefine (MapType) is included to show which map schema was expected. It fires when a value routed to the MAP conversion path is not a Map at runtime.

Source

Thrown at seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java:158

            default:
                throw new UnsupportedOperationException(
                        "Unsupported convert "
                                + value.getClass()
                                + " to "
                                + columnDefine.getDataType().getSqlType());
        }
    }

    default Map convertMap(T typeDefine, Column columnDefine, Object value)
            throws UnsupportedOperationException {
        return convertMap((MapType) columnDefine.getDataType(), value);
    }

    default Map convertMap(MapType typeDefine, Object value) throws UnsupportedOperationException {
        if (value instanceof Map) {
            return (Map) value;
        }
        throw new UnsupportedOperationException(
                "Unsupported convert " + value.getClass() + " to Map, typeDefine: " + typeDefine);
    }

    default Object[] convertArray(T typeDefine, Column columnDefine, Object value)
            throws UnsupportedOperationException {
        return convertArray((ArrayType) columnDefine.getDataType(), value);
    }

    default Object[] convertArray(ArrayType typeDefine, Object value)
            throws UnsupportedOperationException {
        if (value.getClass().isArray()) {
            SeaTunnelDataType elementType = typeDefine.getElementType();

            Object[] array = (Object[]) value;
            for (int i = 0; i < array.length; i++) {
                array[i] = convert(elementType, array[i]);
            }
            return array;

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Parse or convert the value to a java.util.Map before handing it to the converter (e.g. with Jackson for JSON strings).
  2. If the value is a List of pairs, transform it into a LinkedHashMap manually.
  3. Override convertMap in your converter subclass to accept the actual runtime type.
  4. Verify the column SqlType is MAP; if the data is really a string, change the schema instead.

Example fix

// before
converter.convertMap(mapType, jsonString);
// after
Map<String, Object> map = new ObjectMapper().readValue(jsonString, new TypeReference<Map<String, Object>>() {});
converter.convertMap(mapType, map);
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(value instanceof Map)) {
    throw new IllegalArgumentException("convertMap expects java.util.Map, got " + value.getClass());
}

Type guard

boolean isMapValue(Object value) { return value instanceof Map; }

Try / catch

try {
    return converter.convertMap(mapType, value);
} catch (UnsupportedOperationException e) {
    LOG.warn("Not a Map: {}", e.getMessage());
    return Collections.emptyMap();
}

Prevention

When it happens

Trigger: Calling convertMap(typeDefine, value) directly, or convert(...) with a MAP SqlType column, when value is a List, POJO, JSON string, or other non-Map object.

Common situations: Passing a JSON string that was never parsed into a Map; passing a List of key-value pairs hoping the converter will zip them; upstream framework (e.g. a NoSQL driver) returning its own document type not extending java.util.Map.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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