{"record":{"id":"4cc554eac740bd6d","repo":"apache/seatunnel","slug":"unsupported-convert-value-getclass-to-bigdeci","errorCode":null,"errorMessage":"Unsupported convert ${value.getClass()} to BigDecimal, typeDefine: ${typeDefine}","messagePattern":"Unsupported convert (.+?) to BigDecimal, typeDefine: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":822,"sourceCode":"                            0,\n                            ZoneId.systemDefault().getRules().getOffset(LocalDateTime.now()))\n                    .toLocalDate();\n        }\n        return new Date(value.longValue()).toInstant().atZone(ZoneId.systemDefault()).toLocalDate();\n    }\n\n    default BigDecimal convertDecimal(T typeDefine, Object value)\n            throws UnsupportedOperationException {\n        if (value instanceof BigDecimal) {\n            return (BigDecimal) value;\n        }\n        if (value instanceof Number) {\n            return convertDecimal(typeDefine, (Number) value);\n        }\n        if (value instanceof String) {\n            return convertDecimal(typeDefine, (String) value);\n        }\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \"\n                        + value.getClass()\n                        + \" to BigDecimal, typeDefine: \"\n                        + typeDefine);\n    }\n\n    default BigDecimal convertDecimal(T typeDefine, Number value) {\n        return convertDecimal(value);\n    }\n\n    default BigDecimal convertDecimal(T typeDefine, String value) {\n        return convertDecimal(value);\n    }\n\n    default BigDecimal convertDecimal(Object value) throws UnsupportedOperationException {\n        if (value instanceof BigDecimal) {\n            return (BigDecimal) value;\n        }","sourceCodeStart":804,"sourceCodeEnd":840,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L804-L840","documentation":"convertDecimal(TypeDefine, Object) accepts Number and String (and BigDecimal-like values via the Number branch); any other class results in UnsupportedOperationException carrying the typeDefine. The library throws it because a DECIMAL target requires a numeric or parseable numeric-string input and the value is neither.","triggerScenarios":"Calling convert() for a DECIMAL column with e.g. a byte[], boolean, nested object, or binary-encoded decimal not matched by the Number/String branches.","commonSituations":"Fixed-length binary decimals (e.g. from CDC or Parquet decimal logical types) arriving as byte[]; schema drift making a numeric column deserialize as an object; passing pre-formatted currency strings with symbols that fail elsewhere.","solutions":["Inspect value.getClass() in the message; pre-convert binary decimals (e.g. new BigDecimal(new BigInteger(bytes), scale)) before calling convert","Convert the value to a plain numeric String or Number first","Add a custom DataConverter for the offending class if it recurs from the source","Fix the schema mapping so the field arrives as Number/String"],"exampleFix":"// before\nconverter.convert(decimalTypeDefine, decimalBytes); // byte[]\n// after\nBigDecimal bd = new BigDecimal(new BigInteger(decimalBytes), scale);\nconverter.convert(decimalTypeDefine, bd);","handlingStrategy":"type-guard","validationCode":"if (!(v instanceof Number) && !(v instanceof String)) {\n    throw new IllegalStateException(\"Unsupported decimal class: \" + v.getClass());\n}","typeGuard":"boolean isDecimalLike(Object v) {\n    return v instanceof Number || v instanceof String;\n}","tryCatchPattern":"try {\n    converter.convert(typeDefine, value);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"Decimal conversion failed for {}: {}\", value.getClass(), e.getMessage());\n    value = normalizeToDecimal(value); // e.g. decode binary decimal\n}","preventionTips":["Decode binary/fixed-point decimals (byte[]) to BigDecimal before conversion","Ensure numeric columns deserialize as Number, not wrapper objects","Test decimal paths against real source payloads"],"tags":["java","type-conversion","decimal","bigdecimal"],"backgroundTag":"type-mismatch","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}