apache/seatunnel · error · UnsupportedOperationException

Unsupported convert ${value.getClass()} to Float

Error message

Unsupported convert ${value.getClass()} to Float

What it means

Thrown by BasicDataConverter.convertFloat(Object value) when the value is neither a Number nor a String; the typeDefine-less overload is reached when callers rely on the default conversion path. The message prints the offending value class so the developer knows which unexpected type arrived at a FLOAT conversion point.

Source

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

    default float convertFloat(T typeDefine, Number value) {
        return convertFloat(value);
    }

    default float convertFloat(T typeDefine, String value) {
        return convertFloat(value);
    }

    default float convertFloat(Object value) throws UnsupportedOperationException {
        if (value instanceof Float) {
            return (float) value;
        }
        if (value instanceof Number) {
            return convertFloat((Number) value);
        }
        if (value instanceof String) {
            return convertFloat((String) value);
        }
        throw new UnsupportedOperationException(
                "Unsupported convert " + value.getClass() + " to Float");
    }

    default float convertFloat(Number value) {
        return value.floatValue();
    }

    default float convertFloat(String value) {
        return Float.parseFloat(value);
    }

    default long convertLong(T typeDefine, Object value) throws UnsupportedOperationException {
        if (value instanceof Long) {
            return (long) value;
        }
        if (value instanceof Number) {
            return convertLong(typeDefine, (Number) value);
        }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Match the value class in the message to the expected FLOAT input types (Number/String) and fix the upstream schema or field extraction
  2. Convert the value explicitly before calling convertFloat (e.g. Boolean ? 1f : 0f, or parse String)
  3. Override convertFloat(Object value) in a project-specific converter to add the missing class branch

Example fix

// before
float f = converter.convertFloat(row.getField(0)); // throws for Boolean
// after
Object v = row.getField(0);
float f = (v instanceof Boolean) ? ((Boolean) v ? 1f : 0f) : converter.convertFloat(v);
Defensive patterns

Strategy: type-guard

Validate before calling

Object v = row.getField(0);
if (!(v instanceof Number) && !(v instanceof String)) {
    throw new IllegalArgumentException("Value " + v.getClass() + " cannot be converted to float");
}

Type guard

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

Try / catch

try {
    f = converter.convertFloat(value);
} catch (UnsupportedOperationException e) {
    LOG.warn("Cannot convert {} to float", value.getClass());
    f = 0f;
}

Prevention

When it happens

Trigger: Invoking convertFloat(value) (or convertFloat with a null typeDefine path) with an object that is not Number/String — e.g. byte[], LocalDate, Boolean, Map or other POJO — when converting a row field to a float.

Common situations: Same as its typeDefine sibling: source/sink schema drift (field actually Date or binary but declared FLOAT), custom code calling the convenience overload directly with unconverted objects, or a connector emitting deserialized JSON objects into numeric columns.

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/3a6acc7936b2deb3. Report an issue: GitHub.