apache/druid · error · UnsupportedOperationException

HistogramBufferAggregator does not support getDouble

Error message

HistogramBufferAggregator does not support getDouble

What it means

HistogramBufferAggregator.getDouble() throws UnsupportedOperationException (note the message omits the trailing parentheses) because a histogram aggregate cannot be reduced to one double. The BufferAggregator interface provides getDouble(), but this implementation intentionally rejects it. The error means DOUBLE access was requested on a histogram metric in a buffer-based query path.

Source

Thrown at processing/src/main/java/org/apache/druid/query/aggregation/HistogramBufferAggregator.java:105

    return new Histogram(breaks, bins, min, max);
  }

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

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

  @Override
  public double getDouble(ByteBuffer buf, int position)
  {
    throw new UnsupportedOperationException("HistogramBufferAggregator 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. Read the result with get(ByteBuffer, int) and use the returned Histogram object.
  2. Switch to a double-producing aggregator (doubleSum, doubleMean) if a DOUBLE output is needed.
  3. Remove double-typed post-aggregators/casts from the histogram metric in the query spec.
  4. Harden result-extraction code to detect non-numeric aggregators and use object access instead.

Example fix

// before
double d = bufferAgg.getDouble(buf, position); // throws
// after
Object val = bufferAgg.get(buf, position);
double min = (val instanceof Histogram) ? ((Histogram) val).min : Double.NaN;
Defensive patterns

Strategy: type-guard

Validate before calling

if (bufferAggregator instanceof HistogramBufferAggregator) {
  // use get(buf, position) (Histogram), not getDouble()
}

Type guard

boolean supportsDouble(BufferAggregator agg) {
  return !(agg instanceof HistogramBufferAggregator);
}

Try / catch

try {
  value = agg.getDouble(buf, position);
} catch (UnsupportedOperationException e) {
  Histogram h = (Histogram) agg.get(buf, position);
}

Prevention

When it happens

Trigger: A buffer-based query (groupBy/timeseries) with a 'histogram' aggregator whose metric is read via getDouble(ByteBuffer, int); DOUBLE coercion in SQL; double-typed post-aggregators (arithmetic, doubleMean, doubleGreatest) referencing the histogram column.

Common situations: Replacing a doubleSum metric with histogram while keeping downstream DOUBLE accessors; SQL queries where Calcite infers DOUBLE for the output; generic result-extraction code that always calls getDouble(); analytics dashboards expecting numeric metrics from histogram aggregators.

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/97e58d4ce4eaed6a. Report an issue: GitHub.