{"record":{"id":"8dfa40db60a8330d","repo":"apache/druid","slug":"could-not-convert-value-s-to-float","errorCode":null,"errorMessage":"Could not convert value [%s] to float.","messagePattern":"Could not convert value \\[(.+?)\\] to float\\.","errorType":"validation","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/DimensionHandlerUtils.java","lineNumber":514,"sourceCode":"      } else if (valObj instanceof Number) {\n        return ((Number) valObj).floatValue();\n      } else if (valObj instanceof String) {\n        Float ret = Floats.tryParse((String) valObj);\n        if (reportParseExceptions && ret == null) {\n          final String message;\n          if (fieldName != null) {\n            message = StringUtils.nonStrictFormat(\n                \"Could not convert value [%s] to float for dimension [%s].\",\n                valObj,\n                fieldName\n            );\n          } else {\n            message = StringUtils.nonStrictFormat(\n                \"Could not convert value [%s] to float.\",\n                valObj\n            );\n          }\n          throw new ParseException((String) valObj, message);\n        }\n        return ret;\n      } else if (valObj instanceof List) {\n        final String message;\n        if (fieldName != null) {\n          message = StringUtils.nonStrictFormat(\n              \"Could not ingest value [%s] as float for dimension [%s]. A float column cannot have multiple values in the same row.\",\n              valObj,\n              fieldName\n          );\n        } else {\n          message = StringUtils.nonStrictFormat(\n              \"Could not ingest value [%s] as float. A float column cannot have multiple values in the same row.\",\n              valObj\n          );\n        }\n        throw new ParseException(\n            valObj.getClass().toString(),","sourceCodeStart":496,"sourceCodeEnd":532,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/DimensionHandlerUtils.java#L496-L532","documentation":"DimensionHandlerUtils.convertObjectToFloat converts values to float; when a String value cannot be parsed as a float (Float.parseFloat fails), this ParseException is thrown. It means text data doesn't match the declared float column type.","triggerScenarios":"Ingesting \"abc\", \"1,5\", or empty string into a column typed float; convertObjectToFloat invoked with a non-numeric string.","commonSituations":"Locale decimal commas (\"3,14\") in input; whitespace or currency symbols in numbers; malformed rows in CSV/TSV feeds mapped to float columns.","solutions":["Normalize the string in a transform (replace comma decimal separator, trim) before float conversion.","Fix upstream producers to emit parseable floats (e.g. \"3.14\").","Change column type to string if values are not reliably numeric.","Configure ingestion error tolerance (maxParseExceptions / use of error handlers) so bad rows are logged instead of failing the job."],"exampleFix":"// before: value \"1,234.5\" fails Float.parseFloat\n// after: transform strips commas\n\"transforms\": [{\"type\": \"expression\", \"name\": \"price\", \"expression\": \"CAST(replace(price, ',', '') AS DOUBLE)\"}]","handlingStrategy":"try-catch","validationCode":"boolean isParsableFloat(Object v) {\n  if (v == null) return true;\n  if (v instanceof Number) return true;\n  if (v instanceof String) {\n    try { Float.parseFloat(((String) v).trim()); return true; } catch (NumberFormatException e) { return false; }\n  }\n  return false;\n}","typeGuard":"Float asFloat(Object v) {\n  if (v instanceof Number) return ((Number) v).floatValue();\n  if (v instanceof String) { try { return Float.parseFloat(((String) v).trim()); } catch (NumberFormatException e) { return null; } }\n  return null;\n}","tryCatchPattern":"try {\n  return DimensionHandlerUtils.convertObjectToFloat(value, fieldName);\n} catch (ParseException e) {\n  log.warn(\"Non-float value [%s] for field [%s], skipping\", value, fieldName);\n  return null;\n}","preventionTips":["Normalize decimal separators and trim whitespace before conversion","Reject placeholder strings (\"N/A\", \"\") upstream or map to null","Sample and validate CSV/JSON fields before declaring float columns","Tune maxParseExceptions for dirty feeds"],"tags":["ingestion","type-conversion","parse-exception"],"backgroundTag":"invalid-argument-format","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}