apache/druid · error · java.lang.UnsupportedOperationException

ApproximateHistogramBufferAggregator does not support getDou

Error message

ApproximateHistogramBufferAggregator does not support getDouble()

What it means

ApproximateHistogramBufferAggregator.getDouble() is deliberately unimplemented because the aggregator's output is an ApproximateHistogram object, not a double. There is no defined double representation of the histogram, so the method throws UnsupportedOperationException unconditionally.

Source

Thrown at extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramBufferAggregator.java:76

  }

  @Override
  public float getFloat(ByteBuffer buf, int position)
  {
    throw new UnsupportedOperationException("ApproximateHistogramBufferAggregator does not support getFloat()");
  }


  @Override
  public long getLong(ByteBuffer buf, int position)
  {
    throw new UnsupportedOperationException("ApproximateHistogramBufferAggregator does not support getLong()");
  }

  @Override
  public double getDouble(ByteBuffer buf, int position)
  {
    throw new UnsupportedOperationException("ApproximateHistogramBufferAggregator 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)

Solutions

  1. Use histogram-specific post-aggregators (e.g. quantile, quantiles, min, max) to obtain numeric values.
  2. If a plain double metric is needed, use doubleSum/doubleMin/doubleMax on the raw column instead of approxHistogram.
  3. In generic code, check the aggregator's supported types or catch UnsupportedOperationException and fall back to object-based access.

Example fix

// before
double v = bufferAggregator.getDouble(buf, position);
// after
// query with histogram post-aggregator:
// {"type": "min", "fieldName": "approxHist"}
double v = minPostAggResult;
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the aggregator is not histogram-based before getDouble:
boolean isHistogram = aggregator instanceof org.apache.druid.query.aggregation.histogram.ApproximateHistogramBufferAggregator;
if (!isHistogram) { value = aggregator.getDouble(buf, position); }

Type guard

boolean supportsDouble(Object agg) {
  return !(agg instanceof org.apache.druid.query.aggregation.histogram.ApproximateHistogramBufferAggregator);
}

Try / catch

try {
  value = aggregator.getDouble(buf, position);
} catch (UnsupportedOperationException e) {
  value = quantilePostAgg(buf, position);
}

Prevention

When it happens

Trigger: Calling ApproximateHistogramBufferAggregator.getDouble(ByteBuffer, int), or executing a query whose result extraction invokes getDouble on a buffer-aggregated approxHistogram column.

Common situations: Queries expecting double metrics from every aggregator; framework code iterating BufferAggregator results numerically; misconfiguring the query so the histogram fold result is read directly as a double.

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


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/cef78cc66045ed6b. Report an issue: GitHub.