apache/druid · error · java.lang.UnsupportedOperationException
ApproximateHistogramFoldingBufferAggregator does not…
Error message
ApproximateHistogramFoldingBufferAggregator does not support getLong()
What it means
ApproximateHistogramFoldingBufferAggregator.getLong() is deliberately unimplemented: the buffered aggregation produces an ApproximateHistogram, and no long representation exists. The method throws UnsupportedOperationException unconditionally when invoked.
Solutions
- Extract numbers via histogram post-aggregators (quantile, min, max) rather than getLong().
- Use a long-capable aggregator (longSum, longMax) on the raw column when a long result is needed.
- In generic code, check aggregator output type or catch UnsupportedOperationException and fall back to histogram object access.
Example fix
// before
long v = bufferAggregator.getLong(buf, position);
// after
// query JSON:
// {"type": "min", "fieldName": "histFold"}
long v = (long) minPostAggResult; Defensive patterns
Strategy: validation
Validate before calling
// Verify long support before buffered accessor call:
boolean isFoldBuffer = aggregator instanceof org.apache.druid.query.aggregation.histogram.ApproximateHistogramFoldingBufferAggregator;
if (!isFoldBuffer) { value = aggregator.getLong(buf, position); } Type guard
boolean supportsLong(Object agg) {
return !(agg instanceof org.apache.druid.query.aggregation.histogram.ApproximateHistogramFoldingBufferAggregator);
} Try / catch
try {
value = aggregator.getLong(buf, position);
} catch (UnsupportedOperationException e) {
value = (long) maxFromHistogramBuffer(buf, position);
} Prevention
- Do not call getLong on histogram folding buffer aggregators; it is unsupported by design.
- Use long-capable aggregators when long output is required.
- Keep a mapping of aggregator types to supported accessor methods in custom query engines.
When it happens
Trigger: Calling ApproximateHistogramFoldingBufferAggregator.getLong(ByteBuffer, int), or queries whose result extraction path invokes getLong on a buffer-aggregated approxHistogramFold column.
Common situations: Engine code assuming every BufferAggregator implements getLong; queries mixing histogram folds with long-typed metric expectations; custom post-processing that reads raw aggregation buffers numerically.
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…
- ApproximateHistogramBufferAggregator does not support…
- ApproximateHistogramBufferAggregator does not support…
- ApproximateHistogramFoldingAggregator does not support…
- ApproximateHistogramFoldingAggregator does not support…
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/d265d48898c73b22.
Report an issue: GitHub.
Appendix: source
Thrown at extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramFoldingBufferAggregator.java:72
innerAggregator.aggregate(buf, position, hNext);
}
@Override
public Object get(ByteBuffer buf, int position)
{
return innerAggregator.get(buf, position);
}
@Override
public float getFloat(ByteBuffer buf, int position)
{
throw new UnsupportedOperationException("ApproximateHistogramFoldingBufferAggregator does not support getFloat()");
}
@Override
public long getLong(ByteBuffer buf, int position)
{
throw new UnsupportedOperationException("ApproximateHistogramFoldingBufferAggregator does not support getLong()");
}
@Override
public double getDouble(ByteBuffer buf, int position)
{
throw new UnsupportedOperationException("ApproximateHistogramFoldingBufferAggregator does not support getDouble()");
}
@Override
public void close()
{
// no resources to cleanup
}
@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
{
inspector.visit("selector", selector);View on GitHub (pinned to 9b90983fd2)