apache/druid · error · UnsupportedOperationException
StringAnyAggregator does not support getFloat()
Error message
StringAnyAggregator does not support getFloat()
What it means
StringAnyAggregator stores an arbitrary string value, so its getFloat() accessor is meaningless and deliberately throws UnsupportedOperationException with this message. The aggregator API exposes typed getters and calling a numeric getter on a string aggregator is an API misuse that the class rejects eagerly rather than returning a wrong value.
Solutions
- Use getString() on the aggregator's result instead of getFloat(); adjust post-aggregators to string-capable ones (stringFormat/cast post-aggregators)
- If a numeric value is required, aggregate the underlying numeric column directly (doubleAny/doubleSum) instead of its string form
- Wrap the string result with a cast post-aggregator (e.g. string-to-double) before feeding numeric post-aggregators
- Fix the query planner/spec so the aggregator's result type matches what downstream code reads
Example fix
// before
new ArithmeticPostAggregator("p", "+", List.of(new FieldAccessPostAggregator("a", "stringAnyMetric")))
// after
new CastPostAggregator("aAsDouble", new FieldAccessPostAggregator("a", "stringAnyMetric"), "DOUBLE", null) Defensive patterns
Strategy: type-guard
Validate before calling
// Confirm metric type before wiring a numeric post-aggregator
if (aggregator instanceof StringAnyAggregator) {
throw new ISE("stringAny metric cannot feed a numeric post-aggregator");
} Type guard
boolean isStringAggregator(Aggregator a) { return a instanceof StringAnyAggregator; } Try / catch
try {
float f = aggregator.getFloat();
} catch (UnsupportedOperationException e) {
String s = aggregator.getString();
// fall back to string handling / cast
} Prevention
- Match post-aggregator input types to aggregator output types (string vs numeric)
- Use CastPostAggregator to convert string results before numeric operations
- Prefer aggregating the numeric column directly over string representations
- Add type checks in query-building code that consumes aggregator results generically
When it happens
Trigger: A query's post-aggregator or result layer calls getFloat() on the result of a stringAny (or filtered any over a string column) aggregator; e.g. a numeric post-aggregator (arithmetic, cast) wired to a string-typed any-aggregator output.
Common situations: Building native JSON queries by hand and pointing a doubleSum/arithmetic post-aggregator at a stringAny metric; SQL layer mis-mapping where a VARCHAR expression is aggregated with any and then treated numerically downstream.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- StringAnyAggregator does not support getDouble()
- StringAnyAggregator does not support getLong()
- Aggregator[ ] cannot vectorize
- ApproximateHistogramBufferAggregator does not support…
- ApproximateHistogramBufferAggregator does not support…
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/34923b160224b275.
Report an issue: GitHub.
Appendix: source
Thrown at processing/src/main/java/org/apache/druid/query/aggregation/any/StringAnyAggregator.java:86
}
if (aggregateMultipleValues) {
return DimensionHandlerUtils.convertObjectToString(objectList);
}
return DimensionHandlerUtils.convertObjectToString(objectList.get(0));
}
return DimensionHandlerUtils.convertObjectToString(object);
}
@Override
public Object get()
{
return foundValue;
}
@Override
public float getFloat()
{
throw new UnsupportedOperationException("StringAnyAggregator does not support getFloat()");
}
@Override
public long getLong()
{
throw new UnsupportedOperationException("StringAnyAggregator does not support getLong()");
}
@Override
public double getDouble()
{
throw new UnsupportedOperationException("StringAnyAggregator does not support getDouble()");
}
@Override
public void close()
{
// no-opView on GitHub (pinned to 9b90983fd2)