apache/druid · error · java.lang.UnsupportedOperationException
ApproximateHistogramFoldingAggregator does not support getLo
Error message
ApproximateHistogramFoldingAggregator does not support getLong()
What it means
ApproximateHistogramFoldingAggregator.getLong() throws UnsupportedOperationException by design: the folded result is an ApproximateHistogram object and no long representation is defined. Any attempt to read the aggregation as a long fails.
Source
Thrown at extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramFoldingAggregator.java:78
}
}
@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 cleanup
}
}
View on GitHub (pinned to 9b90983fd2)
Solutions
- Derive numbers with histogram post-aggregators (quantile, min, max) instead of getLong().
- Use a long-capable aggregator (e.g. longSum) on the raw column when a long is required.
- Add a capability check or try/catch around getLong() in generic code paths.
Example fix
// before
long v = foldingAggregator.getLong();
// after
// use post-aggregation in the query:
// {"type": "max", "fieldName": "histFold"}
long v = (long) maxPostAggResult; Defensive patterns
Strategy: validation
Validate before calling
// Check type before getLong:
boolean isFoldAgg = aggregator instanceof org.apache.druid.query.aggregation.histogram.ApproximateHistogramFoldingAggregator;
if (!isFoldAgg) { value = aggregator.getLong(); } Type guard
boolean supportsLong(Object agg) {
return !(agg instanceof org.apache.druid.query.aggregation.histogram.ApproximateHistogramFoldingAggregator);
} Try / catch
try {
value = aggregator.getLong();
} catch (UnsupportedOperationException e) {
value = (long) histogramMax(aggregator.get());
} Prevention
- Use longSum/longMax for long outputs; reserve approxHistogramFold for histogram analytics.
- Never assume getLong() exists on every Aggregator implementation.
- Add unit coverage for query plans that combine histogram folds with numeric accessors.
When it happens
Trigger: Calling ApproximateHistogramFoldingAggregator.getLong(), or queries that treat approxHistogramFold output as a long-typed metric.
Common situations: Framework code assuming getLong() exists on all aggregators; queries mixing histogram folds with long metric accessors; custom extensions extracting values from aggregator results generically.
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 getFl
- ApproximateHistogramFoldingAggregator does not support getDo
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/761a713bb67cd4c6.
Report an issue: GitHub.