{"record":{"id":"fffe558ad54fa16b","repo":"apache/seatunnel","slug":"unsupported-type-s-for-numeric-minus-fffe55","errorCode":null,"errorMessage":"Unsupported type %s for numeric minus.","messagePattern":"Unsupported type (.+?) for numeric minus\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/utils/ObjectUtils.java","lineNumber":97,"sourceCode":"                    .subtract(BigDecimal.valueOf((byte) subtrahend));\n        } else if (minuend instanceof Long) {\n            return BigDecimal.valueOf((long) minuend)\n                    .subtract(BigDecimal.valueOf((long) subtrahend));\n        } else if (minuend instanceof Float) {\n            return new BigDecimal(minuend.toString())\n                    .subtract(new BigDecimal(subtrahend.toString()));\n        } else if (minuend instanceof Double) {\n            return BigDecimal.valueOf((double) minuend)\n                    .subtract(BigDecimal.valueOf((double) subtrahend));\n        } else if (minuend instanceof BigInteger) {\n            return new BigDecimal(\n                    ((BigInteger) minuend).subtract((BigInteger) subtrahend).toString());\n        } else if (minuend instanceof BigDecimal) {\n            return ((BigDecimal) minuend).subtract((BigDecimal) subtrahend);\n        } else if (minuend instanceof String) {\n            return BigDecimal.valueOf(Long.MAX_VALUE);\n        } else {\n            throw new UnsupportedOperationException(\n                    String.format(\n                            \"Unsupported type %s for numeric minus.\",\n                            minuend.getClass().getSimpleName()));\n        }\n    }\n\n    /**\n     * Compares two comparable objects.\n     *\n     * @return The value {@code 0} if {@code num1} is equal to the {@code num2}; a value less than\n     *     {@code 0} if the {@code num1} is numerically less than the {@code num2}; and a value\n     *     greater than {@code 0} if the {@code num1} is numerically greater than the {@code num2}.\n     * @throws ClassCastException if the compared objects are not instance of {@link Comparable} or\n     *     not <i>mutually comparable</i> (for example, strings and integers).\n     */\n    @SuppressWarnings(\"unchecked\")\n    public static int compare(Object obj1, Object obj2) {\n        Comparable<Object> c1 = (Comparable<Object>) obj1;","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/utils/ObjectUtils.java#L79-L115","documentation":"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.').","triggerScenarios":"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.","commonSituations":"SMALLINT (Short) columns passed to a subtraction transform (Short is handled in plus but not minus); array/binary or temporal columns fed into arithmetic.","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."],"exampleFix":"// before\nObject diff = ObjectUtils.minus(shortValue, shortValue2); // UnsupportedOperationException\n// after\nObject diff = ObjectUtils.minus(shortValue.intValue(), shortValue2.intValue());","handlingStrategy":"type-guard","validationCode":"if (!(minuend instanceof Integer || minuend instanceof Long || minuend instanceof Float\n      || minuend instanceof Double || minuend instanceof BigInteger || minuend instanceof BigDecimal)) {\n    throw new IllegalArgumentException(\"unsupported operand for minus: \" + minuend.getClass());\n}","typeGuard":"boolean minusSupported(Object v) {\n    return v instanceof Integer || v instanceof Long || v instanceof Float || v instanceof Double\n        || v instanceof BigInteger || v instanceof BigDecimal || v instanceof String;\n}","tryCatchPattern":"try {\n    return ObjectUtils.minus(a, b);\n} catch (UnsupportedOperationException e) {\n    return ((Number) a).longValue() - ((Number) b).longValue();\n}","preventionTips":["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."],"tags":["type-error","jdbc","arithmetic"],"backgroundTag":"unsupported-operation","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}