apache/seatunnel · error · IllegalStateException

Unsupported operand type, the minuend type

Error message

Unsupported operand type, the minuend type %s is different with subtrahend type %s.

What it means

ObjectUtils.minus() requires minuend and subtrahend to be of exactly the same Java class. When their classes differ it throws IllegalStateException('Unsupported operand type, the minuend type %s is different with subtrahend type %s.') instead of implicitly coercing types.

Solutions

  1. Cast or convert both operands to a common type before calling minus, e.g. convert both to BigDecimal.
  2. Align the SeaTunnel column types so both fields map to the same Java class.
  3. In your transform, wrap the call in a class check: if (!a.getClass().equals(b.getClass())) normalize first.

Example fix

// before
Object diff = ObjectUtils.minus(intValue, longValue); // IllegalStateException
// after
BigDecimal diff = new BigDecimal(intValue.toString()).subtract(new BigDecimal(longValue.toString()));
Defensive patterns

Strategy: validation

Validate before calling

if (!a.getClass().equals(b.getClass())) {
    throw new IllegalArgumentException("operands must share a type: "
        + a.getClass().getSimpleName() + " vs " + b.getClass().getSimpleName());
}

Type guard

boolean sameType(Object a, Object b) { return a.getClass().equals(b.getClass()); }

Try / catch

try {
    return ObjectUtils.minus(minuend, subtrahend);
} catch (IllegalStateException e) {
    return new BigDecimal(minuend.toString()).subtract(new BigDecimal(subtrahend.toString()));
}

Prevention

When it happens

Trigger: Calling ObjectUtils.minus(minuend, subtrahend) where minuend.getClass() != subtrahend.getClass(), e.g. Integer minus Long, or BigDecimal minus Double.

Common situations: Subtracting values from two different columns whose logical types differ (INTEGER vs BIGINT); mixing a literal (e.g. Integer) with a Long/BigDecimal column value in an arithmetic transform.

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/0a6fac9b9b79d1a9. 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:66

            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) {
            return BigDecimal.valueOf((short) minuend)
                    .subtract(BigDecimal.valueOf((short) subtrahend));
        } else if (minuend instanceof Byte) {
            return BigDecimal.valueOf((byte) minuend)
                    .subtract(BigDecimal.valueOf((byte) subtrahend));
        } else if (minuend instanceof Long) {
            return BigDecimal.valueOf((long) minuend)
                    .subtract(BigDecimal.valueOf((long) subtrahend));
        } else if (minuend instanceof Float) {
            return new BigDecimal(minuend.toString())

View on GitHub (pinned to cf67b549a7)