apache/seatunnel · error · UnsupportedOperationException
Unsupported type for numeric minus.
Error message
Unsupported type %s for numeric minus.
What it means
ObjectUtils.minus() handles Integer, Long, Float, Double, BigInteger, BigDecimal and (as a quirk) String (returning Long.MAX_VALUE). Any other operand type falls through to UnsupportedOperationException('Unsupported type %s for numeric minus.').
Solutions
- Widen the operand to Integer/Long/BigDecimal before calling minus (e.g. ((Number) v).longValue()).
- Change the column type mapping to a supported numeric type (INTEGER, BIGINT, DECIMAL).
- Add an explicit instanceof check and convert unsupported numerics to BigDecimal in the calling code.
Example fix
// before Object diff = ObjectUtils.minus(shortValue, shortValue2); // UnsupportedOperationException // after Object diff = ObjectUtils.minus(shortValue.intValue(), shortValue2.intValue());
Defensive patterns
Strategy: type-guard
Validate before calling
if (!(minuend instanceof Integer || minuend instanceof Long || minuend instanceof Float
|| minuend instanceof Double || minuend instanceof BigInteger || minuend instanceof BigDecimal)) {
throw new IllegalArgumentException("unsupported operand for minus: " + minuend.getClass());
} Type guard
boolean minusSupported(Object v) {
return v instanceof Integer || v instanceof Long || v instanceof Float || v instanceof Double
|| v instanceof BigInteger || v instanceof BigDecimal || v instanceof String;
} Try / catch
try {
return ObjectUtils.minus(a, b);
} catch (UnsupportedOperationException e) {
return ((Number) a).longValue() - ((Number) b).longValue();
} Prevention
- Convert Short/other numerics to Integer or BigDecimal before calling minus.
- Note minus (unlike plus) does not handle Short and String returns a sentinel Long.MAX_VALUE — review String usage.
- Align column type mappings to supported numeric types.
When it happens
Trigger: Calling ObjectUtils.minus(minuend, subtrahend) with matching classes but a type not in the supported set (e.g. Short, Date, byte[]), reaching the final else branch.
Common situations: SMALLINT (Short) columns passed to a subtraction transform (Short is handled in plus but not minus); array/binary or temporal columns fed into arithmetic.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Unsupported operand type, the minuend type
- Unsupported type for numeric plus.
- byte overflow
- short overflow
- Adding missing fields to SELECT clause
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/fffe558ad54fa16b.
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:97
.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())
.subtract(new BigDecimal(subtrahend.toString()));
} else if (minuend instanceof Double) {
return BigDecimal.valueOf((double) minuend)
.subtract(BigDecimal.valueOf((double) subtrahend));
} else if (minuend instanceof BigInteger) {
return new BigDecimal(
((BigInteger) minuend).subtract((BigInteger) subtrahend).toString());
} else if (minuend instanceof BigDecimal) {
return ((BigDecimal) minuend).subtract((BigDecimal) subtrahend);
} else if (minuend instanceof String) {
return BigDecimal.valueOf(Long.MAX_VALUE);
} else {
throw new UnsupportedOperationException(
String.format(
"Unsupported type %s for numeric minus.",
minuend.getClass().getSimpleName()));
}
}
/**
* Compares two comparable objects.
*
* @return The value {@code 0} if {@code num1} is equal to the {@code num2}; a value less than
* {@code 0} if the {@code num1} is numerically less than the {@code num2}; and a value
* greater than {@code 0} if the {@code num1} is numerically greater than the {@code num2}.
* @throws ClassCastException if the compared objects are not instance of {@link Comparable} or
* not <i>mutually comparable</i> (for example, strings and integers).
*/
@SuppressWarnings("unchecked")
public static int compare(Object obj1, Object obj2) {
Comparable<Object> c1 = (Comparable<Object>) obj1;View on GitHub (pinned to cf67b549a7)