apache/druid · error · java.lang.UnsupportedOperationException
ApproximateHistogramFoldingAggregator does not support getFl
Error message
ApproximateHistogramFoldingAggregator does not support getFloat()
What it means
ApproximateHistogramFoldingAggregator folds ApproximateHistogram objects at query time; its result is a histogram, not a primitive float. getFloat() is intentionally unimplemented and throws UnsupportedOperationException whenever called. Numeric values must be derived via post-aggregation on the folded histogram.
Source
Thrown at extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramFoldingAggregator.java:72
}
if (h.binCount() + histogram.binCount() <= tmpBufferB.length) {
histogram.foldFast(h, tmpBufferP, tmpBufferB);
} else {
histogram.foldFast(h);
}
}
@Override
public Object get()
{
return histogram;
}
@Override
public float getFloat()
{
throw new UnsupportedOperationException("ApproximateHistogramFoldingAggregator does not support getFloat()");
}
@Override
public long getLong()
{
throw new UnsupportedOperationException("ApproximateHistogramFoldingAggregator does not support getLong()");
}
@Override
public double getDouble()
{
throw new UnsupportedOperationException("ApproximateHistogramFoldingAggregator does not support getDouble()");
}
@Override
public void close()
{
// no resources to cleanupView on GitHub (pinned to 9b90983fd2)
Solutions
- Use histogram post-aggregators (quantile, min, max, etc.) on the folded histogram to get numeric results.
- Switch to a numeric aggregator (doubleSum, etc.) if a float/double output is actually needed.
- Catch UnsupportedOperationException in generic aggregation loops and skip non-numeric aggregators.
Example fix
// before
float v = foldingAggregator.getFloat();
// after
// in query JSON use:
// {"type": "quantile", "fieldName": "histFold", "probability": 0.5}
float v = (float) quantileResult; Defensive patterns
Strategy: validation
Validate before calling
// Guard before calling getFloat on a folding aggregator:
if (aggregator instanceof org.apache.druid.query.aggregation.histogram.ApproximateHistogramFoldingAggregator) {
// not supported; use post-aggregation instead
} Type guard
boolean supportsFloat(Object agg) {
return !(agg instanceof org.apache.druid.query.aggregation.histogram.ApproximateHistogramFoldingAggregator);
} Try / catch
try {
value = aggregator.getFloat();
} catch (UnsupportedOperationException e) {
value = (float) histogramQuantile(aggregator.get());
} Prevention
- Only query approxHistogramFold results through histogram post-aggregators.
- When migrating queries from numeric aggregators, update all value-extraction paths, not just the aggregation spec.
- Check AggregatorFactory.getType() before selecting an accessor.
When it happens
Trigger: Calling ApproximateHistogramFoldingAggregator.getFloat(), or a query path requesting a float accessor on an approxHistogramFold aggregation.
Common situations: Using approxHistogramFold where a float metric aggregator is expected; generic code that calls getFloat() on every Aggregator; older queries migrated from numeric aggregators to histogram aggregators without updating output handling.
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
- ApproximateHistogramBufferAggregator does not support getFlo
- ApproximateHistogramBufferAggregator does not support getLon
- ApproximateHistogramBufferAggregator does not support getDou
- ApproximateHistogramFoldingAggregator does not support getLo
- ApproximateHistogramFoldingAggregator does not support getDo
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/1e6d8f12a146f678.
Report an issue: GitHub.