apache/seatunnel · error · IllegalArgumentException
Unable to convert to decimal from unexpected value '${value}
Error message
Unable to convert to decimal from unexpected value '${value}' of type ${value.getClass()} What it means
TiDB CDC's createDecimalConverter converts values to BigDecimal for DECIMAL columns and only accepts Long, Double, and BigDecimal inputs. Any other type (String, byte[], etc.) triggers an IllegalArgumentException naming the offending value and class.
Source
Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-tidb/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/tidb/source/converter/DefaultDataConverter.java:218
} else if (value instanceof Double) {
return ((Double) value).floatValue();
} else {
return Float.parseFloat(value.toString());
}
}
private static Object createDecimalConverter(Object value) {
BigDecimal result;
if (value instanceof String) {
result = new BigDecimal((String) value);
} else if (value instanceof Long) {
result = new BigDecimal(Long.parseLong(value.toString()));
} else if (value instanceof Double) {
result = BigDecimal.valueOf(Double.parseDouble(value.toString()));
} else if (value instanceof BigDecimal) {
result = (BigDecimal) value;
} else {
throw new IllegalArgumentException(
"Unable to convert to decimal from unexpected value '"
+ value
+ "' of type "
+ value.getClass());
}
return result;
}
public Object[] convertToArray(Object value) throws SQLException {
String[] array = ((String) value).split(",");
if (array == null) {
return null;
}
return array;
}
private static Object convertToBinary(Object value) {
if (value instanceof byte[]) {View on GitHub (pinned to cf67b549a7)
Solutions
- Inspect the actual runtime type and extend/patch the converter branch to handle it (e.g. new BigDecimal(value.toString()) for Strings)
- Ensure the SeaTunnel TiDB CDC row's schema matches the real TiDB column type
- Align connector versions so TiDB CDC emits the expected numeric classes
- Pre-coerce values in an upstream transform before they reach the converter
Example fix
// before
} else {
throw new IllegalArgumentException(...);
}
// after
} else if (value instanceof String) {
result = new BigDecimal((String) value);
} else {
throw new IllegalArgumentException(...);
} Defensive patterns
Strategy: type-guard
Validate before calling
static boolean isDecimalConvertible(Object v) {
return v instanceof Long || v instanceof Double || v instanceof BigDecimal;
} Type guard
static BigDecimal toDecimalSafe(Object v) {
if (v instanceof BigDecimal) return (BigDecimal) v;
if (v instanceof Long || v instanceof Double) return new BigDecimal(v.toString());
if (v instanceof String) return new BigDecimal((String) v);
return null; // caller decides to fail
} Try / catch
try {
return converter.convert(decimalType, value);
} catch (IllegalArgumentException e) {
log.warn("Decimal conversion failed for {} : {}", value.getClass(), e.getMessage());
throw e;
} Prevention
- Ensure TiDB column types match the SeaTunnel schema mapping
- Add a String branch to the converter if TiDB CDC emits strings for decimals
- Pin compatible connector and TiDB CDC versions
When it happens
Trigger: convert() meets a DECIMAL column whose runtime value is not Long/Double/BigDecimal — commonly a String from the TiKV puller or a java.lang.Byte/Short/Integer variant.
Common situations: Schema drift where TiDB column type changed from DECIMAL to VARCHAR but cached schema still says DECIMAL; TiDB CDC version emitting different value classes after an upgrade.
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
- Unable to convert to LocalDateTime from unexpected value '${
- Invalid bytes for Decimal field
- Unsupported convert ${value.getClass()} to BigDecimal, typeD
- Unsupported convert ${value.getClass()} to BigDecimal
- Unsupported BYTES value type: ${value.getClass().getSimpleNa
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/442ba6e75a1f089a.
Report an issue: GitHub.