apache/druid · error · java.lang.UnsupportedOperationException

FixedBucketsHistogramBufferAggregator does not support getDo

Error message

FixedBucketsHistogramBufferAggregator does not support getDouble()

What it means

FixedBucketsHistogramBufferAggregator.getDouble() unconditionally throws UnsupportedOperationException. The histogram metric is a complex object and cannot yield a double from its aggregation buffer; the method exists only to satisfy the BufferAggregator interface and always fails.

Source

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

    return innerAggregator.get(buf, position);
  }

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

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

  @Override
  public double getDouble(ByteBuffer buf, int position)
  {
    throw new UnsupportedOperationException("FixedBucketsHistogramBufferAggregator 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 the provided histogram post-aggregators to extract scalars (e.g. quantile, min, max) before any numeric use.
  2. Set the query to finalize the metric so the result is a serialized FixedBucketsHistogram, handled by the serde.
  3. Treat the column as complex type in the query plan rather than DOUBLE.

Example fix

// before
double v = agg.getDouble(buf, pos);
// after
// {"type": "quantile", "fieldName": "myHist", "probability": 0.95}
Defensive patterns

Strategy: type-guard

Validate before calling

if (aggregator instanceof FixedBucketsHistogramBufferAggregator) {
  throw new IllegalStateException("Use histogram post-aggregators, not double reads");
}

Type guard

boolean supportsDouble(BufferAggregator a) {
  return !(a instanceof FixedBucketsHistogramBufferAggregator);
}

Try / catch

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

Prevention

When it happens

Trigger: Any code path calls getDouble() on the buffer for a fixedBucketsHistogram metric, such as a double-typed post-aggregator, SQL DOUBLE projection, or direct framework access to the buffer.

Common situations: Users expecting the histogram to behave like a double aggregator (e.g. average) and projecting it as DOUBLE in SQL or native queries; custom vector/frame reading code.

Related errors


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