{"record":{"id":"d3cb775901144c59","repo":"apache/seatunnel","slug":"cannot-convert-to-float","errorCode":null,"errorMessage":"Cannot convert to float: ","messagePattern":"Cannot convert to float: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-iceberg/src/main/java/org/apache/seatunnel/connectors/seatunnel/iceberg/data/RowConverter.java","lineNumber":305,"sourceCode":"        throw new IllegalArgumentException(\"Cannot convert to int: \" + value.getClass().getName());\n    }\n\n    protected long convertLong(Object value) {\n        if (value instanceof Number) {\n            return ((Number) value).longValue();\n        } else if (value instanceof String) {\n            return Long.parseLong((String) value);\n        }\n        throw new IllegalArgumentException(\"Cannot convert to long: \" + value.getClass().getName());\n    }\n\n    protected float convertFloat(Object value) {\n        if (value instanceof Number) {\n            return ((Number) value).floatValue();\n        } else if (value instanceof String) {\n            return Float.parseFloat((String) value);\n        }\n        throw new IllegalArgumentException(\n                \"Cannot convert to float: \" + value.getClass().getName());\n    }\n\n    protected double convertDouble(Object value) {\n        if (value instanceof Number) {\n            return ((Number) value).doubleValue();\n        } else if (value instanceof String) {\n            return Double.parseDouble((String) value);\n        }\n        throw new IllegalArgumentException(\n                \"Cannot convert to double: \" + value.getClass().getName());\n    }\n\n    protected BigDecimal convertDecimal(Object value, Types.DecimalType type) {\n        BigDecimal bigDecimal;\n        if (value instanceof BigDecimal) {\n            bigDecimal = (BigDecimal) value;\n        } else if (value instanceof Number) {","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-iceberg/src/main/java/org/apache/seatunnel/connectors/seatunnel/iceberg/data/RowConverter.java#L287-L323","documentation":"Thrown by RowConverter.convertFloat when an Iceberg field value being converted to a float is neither a Number nor a parseable String; the message names the value's Java class, identifying the incompatible source type.","triggerScenarios":"convertValue targeting an Iceberg FloatType field receives a non-numeric, non-string value.","commonSituations":"Boolean or byte[] data landing in FLOAT columns; CSV readers inferring wrong types; upstream transforms emitting objects instead of primitives.","solutions":["Ensure float fields carry numeric values or numeric strings.","Pre-cast in a transform (CAST(col AS FLOAT)).","Change the Iceberg column type to match actual data.","Catch IllegalArgumentException and skip/redirect bad records."],"exampleFix":"// before\nrow.setField(0, \"1.5x\"); // throws NumberFormatException / or non-number object\n// after\nrow.setField(0, 1.5f);","handlingStrategy":"type-guard","validationCode":"if (!(v instanceof Number) && !(v instanceof String)) { throw new IllegalArgumentException(\"float field expects Number/String, got \" + v.getClass()); }","typeGuard":"Float safeToFloat(Object v) { if (v instanceof Number) return ((Number) v).floatValue(); if (v instanceof String) return Float.valueOf((String) v); return null; }","tryCatchPattern":"try { value = convertFloat(raw); } catch (IllegalArgumentException e) { log.warn(\"Bad float value: {}\", e.getMessage()); }","preventionTips":["Pre-parse numeric strings and validate format","Use CAST to FLOAT in transforms","Check CSV/JSON parser type inference"],"tags":["iceberg","type-conversion","type-mismatch"],"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"}