apache/seatunnel · error · UnsupportedOperationException

Unsupported convert %s to Array, typeDefine: %s

Error message

Unsupported convert %s to Array, typeDefine: %s

What it means

The default convertArray implementation only converts Collection values (including Set) whose elements it can recursively convert; a value of any other class throws this UnsupportedOperationException. typeDefine (ArrayType) identifies the expected array element type. It means the object on the ARRAY conversion path is not a Collection.

Source

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

            return array;
        }
        if (value instanceof List) {
            SeaTunnelDataType elementType = typeDefine.getElementType();

            List<Object> list = (List<Object>) value;
            int elements = list.size();
            for (int i = 0; i < elements; i++) {
                list.set(i, convert(elementType, list.get(i)));
            }
            return list.toArray();
        }
        if (value instanceof Set) {
            SeaTunnelDataType elementType = typeDefine.getElementType();

            return ((Set) value).stream().map(e -> convert(elementType, e)).toArray();
        }

        throw new UnsupportedOperationException(
                "Unsupported convert " + value.getClass() + " to Array, typeDefine: " + typeDefine);
    }

    default SeaTunnelRow convertRow(T typeDefine, Column columnDefine, Object value)
            throws UnsupportedOperationException {
        return convertRow((SeaTunnelRowType) columnDefine.getDataType(), value);
    }

    default SeaTunnelRow convertRow(SeaTunnelRowType typeDefine, Object value)
            throws UnsupportedOperationException {
        if (value instanceof SeaTunnelRow) {
            return (SeaTunnelRow) value;
        }
        if (value instanceof Collection) {
            Collection collection = (Collection) value;
            if (collection.size() != typeDefine.getTotalFields()) {
                throw new IllegalArgumentException(
                        "The size of collection is not equal to the size of row type");

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Convert the array to a List first with java.util.Arrays.asList(...) or a stream before calling the converter.
  2. If value is java.sql.Array, call getArray() and wrap the result in a List.
  3. Override convertArray in a custom converter to handle primitive/native array types.
  4. Check that the column SqlType ARRAY and its element type match the actual data.

Example fix

// before
converter.convertArray(arrayType, jdbcArray.getArray()); // Object[]
// after
Object[] raw = (Object[]) jdbcArray.getArray();
converter.convertArray(arrayType, Arrays.asList(raw));
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(value instanceof Collection)) {
    if (value != null && value.getClass().isArray()) {
        value = Arrays.asList((Object[]) value); // normalize first
    } else {
        throw new IllegalArgumentException("convertArray expects a Collection, got " + value.getClass());
    }
}

Type guard

boolean isCollectionOrArray(Object v) { return v instanceof Collection || (v != null && v.getClass().isArray()); }

Try / catch

try {
    return converter.convertArray(arrayType, value);
} catch (UnsupportedOperationException e) {
    LOG.warn("Array conversion failed: {}", e.getMessage());
    return new Object[0];
}

Prevention

When it happens

Trigger: Calling convertArray(...) or convert(...) with an ARRAY SqlType column when value is a Java array (e.g. int[], Object[]), an Iterable that is not a Collection, or an iterator/POJO.

Common situations: JDBC drivers returning native SQL arrays (java.sql.Array or primitive arrays) instead of Collections; passing a raw Object[] from a legacy API; forgetting that the converter handles Set/List but not arrays.

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/ca4fbf32fe6582f6. Report an issue: GitHub.