apache/seatunnel · error · UnsupportedOperationException

Unsupported convert ${value.getClass()} to BigDecimal, typeD

Error message

Unsupported convert ${value.getClass()} to BigDecimal, typeDefine: ${typeDefine}

What it means

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.

Source

Thrown at seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java:822

                            0,
                            ZoneId.systemDefault().getRules().getOffset(LocalDateTime.now()))
                    .toLocalDate();
        }
        return new Date(value.longValue()).toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
    }

    default BigDecimal convertDecimal(T typeDefine, Object value)
            throws UnsupportedOperationException {
        if (value instanceof BigDecimal) {
            return (BigDecimal) value;
        }
        if (value instanceof Number) {
            return convertDecimal(typeDefine, (Number) value);
        }
        if (value instanceof String) {
            return convertDecimal(typeDefine, (String) value);
        }
        throw new UnsupportedOperationException(
                "Unsupported convert "
                        + value.getClass()
                        + " to BigDecimal, typeDefine: "
                        + typeDefine);
    }

    default BigDecimal convertDecimal(T typeDefine, Number value) {
        return convertDecimal(value);
    }

    default BigDecimal convertDecimal(T typeDefine, String value) {
        return convertDecimal(value);
    }

    default BigDecimal convertDecimal(Object value) throws UnsupportedOperationException {
        if (value instanceof BigDecimal) {
            return (BigDecimal) value;
        }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Inspect value.getClass() in the message; pre-convert binary decimals (e.g. new BigDecimal(new BigInteger(bytes), scale)) before calling convert
  2. Convert the value to a plain numeric String or Number first
  3. Add a custom DataConverter for the offending class if it recurs from the source
  4. Fix the schema mapping so the field arrives as Number/String

Example fix

// before
converter.convert(decimalTypeDefine, decimalBytes); // byte[]
// after
BigDecimal bd = new BigDecimal(new BigInteger(decimalBytes), scale);
converter.convert(decimalTypeDefine, bd);
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(v instanceof Number) && !(v instanceof String)) {
    throw new IllegalStateException("Unsupported decimal class: " + v.getClass());
}

Type guard

boolean isDecimalLike(Object v) {
    return v instanceof Number || v instanceof String;
}

Try / catch

try {
    converter.convert(typeDefine, value);
} catch (UnsupportedOperationException e) {
    LOG.warn("Decimal conversion failed for {}: {}", value.getClass(), e.getMessage());
    value = normalizeToDecimal(value); // e.g. decode binary decimal
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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/4cc554eac740bd6d. Report an issue: GitHub.