apache/seatunnel · error · UnsupportedOperationException

Unsupported type for numeric plus.

Error message

Unsupported type %s for numeric plus.

What it means

ObjectUtils.plus() only supports Byte, Short, Integer, Long, Float, Double, BigInteger and BigDecimal operands. If the number argument is any other type (e.g. String, SeaTunnelRow, Date), it throws UnsupportedOperationException('Unsupported type %s for numeric plus.').

Solutions

  1. Check the field's SeaTunnel type mapping and ensure the value is a numeric type before calling plus().
  2. Convert the value explicitly first, e.g. new BigDecimal(value.toString()) or Long.parseLong(...).
  3. Fix the source/catalog type mapping so numeric columns arrive as Integer/Long/BigDecimal instead of String or other types.

Example fix

// before
Object sum = ObjectUtils.plus(rawValue, 1); // rawValue is String -> UnsupportedOperationException
// after
Object numeric = rawValue instanceof Number ? rawValue : new BigDecimal(rawValue.toString());
Object sum = ObjectUtils.plus(numeric, 1);
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(value instanceof Number)) {
    throw new IllegalArgumentException("plus() requires a Number, got: " + value.getClass());
}

Type guard

boolean isSupportedNumeric(Object v) {
    return v instanceof Byte || v instanceof Short || v instanceof Integer || v instanceof Long
        || v instanceof Float || v instanceof Double || v instanceof BigInteger || v instanceof BigDecimal;
}

Try / catch

try {
    return ObjectUtils.plus(number, augend);
} catch (UnsupportedOperationException e) {
    return new BigDecimal(number.toString()).add(BigDecimal.valueOf(((Number) augend).doubleValue()));
}

Prevention

When it happens

Trigger: Calling ObjectUtils.plus(number, augend) where number's runtime class is none of the supported numeric types, so the final else branch is reached.

Common situations: A JDBC column mapped to an unexpected Java type (e.g. String-typed numeric column from a loosely typed source) is fed into plus() by a transform; custom types from another connector passed into the utility.

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

Appendix: source

Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/utils/ObjectUtils.java:56

            int result = Math.addExact((Short) number, augend);
            if (result < Short.MIN_VALUE || result > Short.MAX_VALUE) {
                throw new ArithmeticException("short overflow");
            }
            return (short) result;
        } else if (number instanceof Integer) {
            return Math.addExact((Integer) number, augend);
        } else if (number instanceof Long) {
            return Math.addExact((Long) number, augend);
        } else if (number instanceof Float) {
            return ((Float) number) + augend;
        } else if (number instanceof Double) {
            return ((Double) number) + augend;
        } else if (number instanceof BigInteger) {
            return ((BigInteger) number).add(BigInteger.valueOf(augend));
        } else if (number instanceof BigDecimal) {
            return ((BigDecimal) number).add(BigDecimal.valueOf(augend));
        } else {
            throw new UnsupportedOperationException(
                    String.format(
                            "Unsupported type %s for numeric plus.",
                            number.getClass().getSimpleName()));
        }
    }

    /** Returns the difference {@code BigDecimal} whose value is {@code (minuend - subtrahend)}. */
    public static BigDecimal minus(Object minuend, Object subtrahend) {
        if (!minuend.getClass().equals(subtrahend.getClass())) {
            throw new IllegalStateException(
                    String.format(
                            "Unsupported operand type, the minuend type %s is different with subtrahend type %s.",
                            minuend.getClass().getSimpleName(),
                            subtrahend.getClass().getSimpleName()));
        }
        if (minuend instanceof Integer) {
            return BigDecimal.valueOf((int) minuend).subtract(BigDecimal.valueOf((int) subtrahend));
        } else if (minuend instanceof Short) {

View on GitHub (pinned to cf67b549a7)