{"record":{"id":"be48b5504fa71b68","repo":"apache/seatunnel","slug":"unsupported-convert-value-getclass-to-float","errorCode":null,"errorMessage":"Unsupported convert ${value.getClass()} to Float, typeDefine: ${typeDefine}","messagePattern":"Unsupported convert (.+?) to Float, typeDefine: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":916,"sourceCode":"    default double convertDouble(Number value) {\n        return value.doubleValue();\n    }\n\n    default double convertDouble(String value) {\n        return Double.parseDouble(value);\n    }\n\n    default float convertFloat(T typeDefine, Object value) throws UnsupportedOperationException {\n        if (value instanceof Float) {\n            return (float) value;\n        }\n        if (value instanceof Number) {\n            return convertFloat(typeDefine, (Number) value);\n        }\n        if (value instanceof String) {\n            return convertFloat(typeDefine, (String) value);\n        }\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \" + value.getClass() + \" to Float, typeDefine: \" + typeDefine);\n    }\n\n    default float convertFloat(T typeDefine, Number value) {\n        return convertFloat(value);\n    }\n\n    default float convertFloat(T typeDefine, String value) {\n        return convertFloat(value);\n    }\n\n    default float convertFloat(Object value) throws UnsupportedOperationException {\n        if (value instanceof Float) {\n            return (float) value;\n        }\n        if (value instanceof Number) {\n            return convertFloat((Number) value);\n        }","sourceCodeStart":898,"sourceCodeEnd":934,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L898-L934","documentation":"This UnsupportedOperationException is thrown by BasicDataConverter.convertFloat(T typeDefine, Object value) when the incoming value is neither a Number nor a String, so the converter has no rule to produce a float. SeaTunnel row converters call this when mapping a source field to a FLOAT column; the message names the actual Java class received and the type definition, so it identifies both the offending type and the target column type. It is a programming/schema mismatch, not a runtime failure that can be retried.","triggerScenarios":"Calling DataConverter.convertFloat(typeDefine, value) with a value object whose class is not java.lang.Number and not java.lang.String — e.g. a byte[] from a binary column, a LocalDate/LocalDateTime, a Map/Array from a struct field, or a BigDecimal subclass not expected by the converter — while the sink column is FLOAT.","commonSituations":"A schema mismatch between source and sink: a source connector deserializes a field as byte[]/Date/Object but the catalog says FLOAT; a custom transform passes raw deserialized objects (e.g. JSON nested objects) into a float column; column type changed in the target table without updating the catalog mapping.","solutions":["Inspect value.getClass() printed in the message and change the upstream schema/catalog so the field is typed as a numeric or string type compatible with FLOAT","Add an explicit conversion before calling the converter (e.g. parse the value to a Number/String) or override convertFloat(T typeDefine, Object value) in a custom converter to handle the reported class","If the value should be skipped/nulled, filter or null-check the field in the transform before conversion"],"exampleFix":"// before\nfloat f = converter.convertFloat(typeDefine, row.getField(i)); // byte[] value throws\n// after\nObject v = row.getField(i);\nfloat f = (v instanceof Number) ? converter.convertFloat(typeDefine, (Number) v)\n        : converter.convertFloat(typeDefine, new String((byte[]) v, StandardCharsets.UTF_8));","handlingStrategy":"type-guard","validationCode":"Object v = row.getField(i);\nif (!(v instanceof Number) && !(v instanceof String)) {\n    throw new IllegalArgumentException(\"Field \" + i + \" of type \" + v.getClass() + \" is not convertible to FLOAT\");\n}","typeGuard":"static boolean isFloatConvertible(Object v) {\n    return v instanceof Number || v instanceof String;\n}","tryCatchPattern":"try {\n    f = converter.convertFloat(typeDefine, value);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"Non-convertible value {} for FLOAT column: {}\", value, e.getMessage());\n    f = 0f; // or skip/null per business rule\n}","preventionTips":["Always verify the value's runtime class against the target SeaTunnel physical type before scalar conversion","Keep the catalog schema in sync with what the source connector actually deserializes","Add unit tests for converters covering every field type your source can emit","Prefer explicit transforms (e.g. cast in a transform step) over relying on default coercion for non-numeric types"],"tags":["java","type-conversion","unsupported-operation"],"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"}