apache/druid · error · ParseException
Could not convert value [%s] to float for dimension [%s]. In
Error message
Could not convert value [%s] to float for dimension [%s]. Invalid type: [%s]
What it means
convertObjectToFloat throws this ParseException when the value's runtime type is not convertible to float (not Number, String, or List — e.g. a Map or boolean). The message reports the value and its class.
Source
Thrown at processing/src/main/java/org/apache/druid/segment/DimensionHandlerUtils.java:551
message
);
} else {
final String message;
if (fieldName != null) {
message = StringUtils.nonStrictFormat(
"Could not convert value [%s] to float for dimension [%s]. Invalid type: [%s]",
valObj,
fieldName,
valObj.getClass()
);
} else {
message = StringUtils.nonStrictFormat(
"Could not convert value [%s] to float. Invalid type: [%s]",
valObj,
valObj.getClass()
);
}
throw new ParseException(
valObj.getClass().toString(),
message
);
}
}
}
@Nullable
public static Object convertObjectToType(
@Nullable final Object obj,
final TypeSignature<ValueType> type,
final boolean reportParseExceptions,
@Nullable final String fieldName
)
{
Preconditions.checkNotNull(type, "type");
switch (type.getType()) {View on GitHub (pinned to 9b90983fd2)
Solutions
- Extract the numeric sub-field with a transform/json_query before conversion.
- Correct upstream serialization so floats are plain numbers.
- Type the column as string (or nested) if data is structured.
- Validate the input schema against samples before submitting the ingestion spec.
Example fix
// before: float column gets {"v": 1.2}
// after: transform extracts v
"transforms": [{"type": "expression", "name": "v", "expression": "CAST(json_value(payload, '$.v') AS DOUBLE)"}] Defensive patterns
Strategy: type-guard
Validate before calling
boolean convertibleToFloat(Object v) {
return v == null || v instanceof Number || v instanceof String;
} Type guard
Float asFloat(Object v) {
if (v instanceof Number) return ((Number) v).floatValue();
if (v instanceof String) { try { return Float.parseFloat((String) v); } catch (NumberFormatException e) { return null; } }
return null;
} Try / catch
try {
return DimensionHandlerUtils.convertObjectToFloat(value, fieldName);
} catch (ParseException e) {
log.warn("Invalid type [%s] for float field [%s], dropping", value.getClass(), fieldName);
return null;
} Prevention
- Verify value.getClass() is Number or String before conversion
- Extract numeric sub-fields from nested objects via json_value transforms
- JSON-schema validate producer payloads
- Watch for auto-detected column types on heterogeneous data
When it happens
Trigger: A float column receives a nested JSON object, boolean, or other unhandled Java type; convertObjectToFloat falls to the final else; also reachable via convertObjectToType.
Common situations: Nested payloads mapped directly to a numeric metric column; heterogeneous upstream schemas; auto-detection mistyping a column as float.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Could not convert value [%s] to long for dimension [%s]. Inv
- Could not convert value [%s] to long.
- Could not ingest value [%s] as long for dimension [%s]. A lo
- Could not convert value [%s] to float.
- 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/4858164bd7457893.
Report an issue: GitHub.