apache/druid · error · ParseException
Could not convert value [%s] to float.
Error message
Could not convert value [%s] to float.
What it means
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.
Source
Thrown at processing/src/main/java/org/apache/druid/segment/DimensionHandlerUtils.java:514
} else if (valObj instanceof Number) {
return ((Number) valObj).floatValue();
} else if (valObj instanceof String) {
Float ret = Floats.tryParse((String) valObj);
if (reportParseExceptions && ret == null) {
final String message;
if (fieldName != null) {
message = StringUtils.nonStrictFormat(
"Could not convert value [%s] to float for dimension [%s].",
valObj,
fieldName
);
} else {
message = StringUtils.nonStrictFormat(
"Could not convert value [%s] to float.",
valObj
);
}
throw new ParseException((String) valObj, message);
}
return ret;
} else if (valObj instanceof List) {
final String message;
if (fieldName != null) {
message = StringUtils.nonStrictFormat(
"Could not ingest value [%s] as float for dimension [%s]. A float column cannot have multiple values in the same row.",
valObj,
fieldName
);
} else {
message = StringUtils.nonStrictFormat(
"Could not ingest value [%s] as float. A float column cannot have multiple values in the same row.",
valObj
);
}
throw new ParseException(
valObj.getClass().toString(),View on GitHub (pinned to 9b90983fd2)
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.
Example fix
// before: value "1,234.5" fails Float.parseFloat
// after: transform strips commas
"transforms": [{"type": "expression", "name": "price", "expression": "CAST(replace(price, ',', '') AS DOUBLE)"}] Defensive patterns
Strategy: try-catch
Validate before calling
boolean isParsableFloat(Object v) {
if (v == null) return true;
if (v instanceof Number) return true;
if (v instanceof String) {
try { Float.parseFloat(((String) v).trim()); return true; } catch (NumberFormatException e) { return false; }
}
return false;
} Type guard
Float asFloat(Object v) {
if (v instanceof Number) return ((Number) v).floatValue();
if (v instanceof String) { try { return Float.parseFloat(((String) v).trim()); } catch (NumberFormatException e) { return null; } }
return null;
} Try / catch
try {
return DimensionHandlerUtils.convertObjectToFloat(value, fieldName);
} catch (ParseException e) {
log.warn("Non-float value [%s] for field [%s], skipping", value, fieldName);
return null;
} Prevention
- 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
When it happens
Trigger: Ingesting "abc", "1,5", or empty string into a column typed float; convertObjectToFloat invoked with a non-numeric string.
Common situations: Locale decimal commas ("3,14") in input; whitespace or currency symbols in numbers; malformed rows in CSV/TSV feeds mapped to float columns.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Could not convert value [%s] to long.
- Could not convert value [%s] to double.
- Could not ingest value [%s] as long for dimension [%s]. A lo
- Could not convert value [%s] to long for dimension [%s]. Inv
- Could not ingest value [%s] as float for dimension [%s]. A f
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/8dfa40db60a8330d.
Report an issue: GitHub.