{"record":{"id":"ac65dd5290327e3a","repo":"apache/iceberg","slug":"cannot-convert-to-float-value-getclass-getnam","errorCode":null,"errorMessage":"Cannot convert to float: ${value.getClass().getName()}","messagePattern":"Cannot convert to float: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"kafka-connect/kafka-connect/src/main/java/org/apache/iceberg/connect/data/RecordConverter.java","lineNumber":447,"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(\"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(\"Cannot convert to double: \" + value.getClass().getName());\n  }\n\n  protected BigDecimal convertDecimal(Object value, DecimalType type) {\n    BigDecimal bigDecimal;\n    if (value instanceof BigDecimal) {\n      bigDecimal = (BigDecimal) value;\n    } else if (value instanceof Number) {\n      Number num = (Number) value;\n      Double dbl = num.doubleValue();","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/kafka-connect/kafka-connect/src/main/java/org/apache/iceberg/connect/data/RecordConverter.java#L429-L465","documentation":"Conversion failure in RecordConverter.convertFloat: the Kafka Connect value for a float-typed field is neither a Number nor a String (the two accepted coercions). The appended class name is the value's runtime type; it signals a schema mismatch between the source record and the Iceberg table column.","triggerScenarios":"A field mapped to an Iceberg FloatType column holding a Boolean, byte[], Map, List, or other non-numeric non-string value.","commonSituations":"Float columns fed boolean JSON values; misconfigured schema mapping; producers sending objects where float is declared.","solutions":["Send numeric or numeric-parsable-string values for float fields.","Change the Iceberg column type to match the actual value type.","Normalize the value with an SMT before the sink connector.","Catch IllegalArgumentException and send the record to a DLQ."],"exampleFix":"// before\nrecord.set(\"ratio\", \"N/A\"); // non-numeric string? no — fails earlier; here: record.set(\"ratio\", true);\n// after\nrecord.set(\"ratio\", 1.0f); // or change column to BOOLEAN","handlingStrategy":"validation","validationCode":"Object v = record.get(\"ratio\");\nif (!(v instanceof Number) && !(v instanceof String)) {\n  throw new IllegalArgumentException(\"ratio must be numeric, got \" + v.getClass().getSimpleName());\n}","typeGuard":"boolean isFloatConvertible(Object v) {\n  return v instanceof Number || v instanceof String;\n}","tryCatchPattern":"try {\n  sink.write(record);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Cannot convert to float\")) {\n    sendToDlq(record, e);\n  } else throw e;\n}","preventionTips":["Avoid sending boolean or placeholder values (\"N/A\", null objects) into float columns.","Prefer float32 in the producer schema when the Iceberg column is FLOAT.","Validate payloads with a schema check before producing."],"tags":["kafka-connect","type-coercion","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}