apache/druid · error · UnsupportedOperationException
Cannot convert object to float
Error message
Cannot convert object to float
What it means
Runtime type guard in the unnest cursor's column value selector: when the unnested cell value is neither null nor a Number (e.g. it is a String or other object), the selector cannot fulfill a primitive-float read and raises this error. It fires when a query reads an unnested column as FLOAT while the actual unnested values are non-numeric; fix by unnesting/coercing values to numbers or selecting the column with a compatible type (string/object).
Source
Thrown at processing/src/main/java/org/apache/druid/segment/UnnestColumnValueSelectorCursor.java:159
return 0;
}
if (value instanceof Number) {
return ((Number) value).doubleValue();
}
throw new UOE("Cannot convert object to double");
}
@Override
public float getFloat()
{
Object value = getObject();
if (value == null) {
return 0;
}
if (value instanceof Number) {
return ((Number) value).floatValue();
}
throw new UOE("Cannot convert object to float");
}
@Override
public long getLong()
{
Object value = getObject();
if (value == null) {
return 0;
}
if (value instanceof Number) {
return ((Number) value).longValue();
}
throw new UOE("Cannot convert object to long");
}
@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
{View on GitHub (pinned to 9b90983fd2)
Solutions
- Coerce column values to numeric before unnesting
- Verify segment schema with segment metadata query and fix the column type at ingestion
- Change the query to use string handling (e.g. CAST in SQL) instead of float selectors
Defensive patterns
Strategy: type-guard
Validate before calling
Object v = selector.getObject();
if (!(v instanceof Number) && v != null) { /* route to string/cast handling */ } Type guard
static boolean isFloatSafe(Object o) { return o == null || o instanceof Number; } Try / catch
try { float f = selector.getFloat(); } catch (UOE e) { /* fallback: parse Object as float */ } Prevention
- Confirm the unnest source column is numeric-typed
- Normalize values to numbers during ingestion
- Prefer SQL-level casts over raw object selectors
When it happens
Trigger: getFloat() called on an UnnestColumnValueSelectorCursor whose underlying getObject() returns a non-Number object (string, map, list, complex).
Common situations: FLOAT aggregations over an unnested column that actually holds strings or objects; schema drift where a segment was written with a different type than the query assumes.
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
- Cannot convert object to double
- Cannot convert object to long
- Cannot deserialize type[%s] to an RoaringBitmap64Counter:
- Expected a number or an instance of MergingDigest, but recei
- Object is not of a type that can be deserialized to a quanti
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/084ca707828f8533.
Report an issue: GitHub.