apache/druid · error · UnsupportedOperationException

HistogramAggregator does not support getFloat()

Error message

HistogramAggregator does not support getFloat()

What it means

HistogramAggregator accumulates a floating-point histogram and exposes getComplexValue()/get(); numeric accessors getFloat()/getLong() are intentionally unsupported and throw UnsupportedOperationException because a histogram is not a scalar number.

Solutions

  1. Use histogram-specific post-aggregators (e.g. quantile/equalBuckets/CustomBuckets) instead of numeric ones
  2. Do not apply arithmetic/numeric post-aggregators to histogram output
  3. Switch to an approximate quantile aggregator (e.g. DataSketches quantiles) if numeric summaries are needed

Example fix

// before
new ArithmeticPostAggregator("q", "+", [fieldAccess("hist")])
// after
new QuantilePostAggregator("q", "hist", 0.5)
Defensive patterns

Strategy: type-guard

Validate before calling

// before numeric post-aggregation
if (aggregatorType.equals("histogram")) {
  throw new IllegalArgumentException("Use histogram post-aggregators (quantile/equalBuckets) instead of numeric accessors");
}

Type guard

boolean supportsNumericAccess(Aggregator agg) {
  return !(agg instanceof HistogramAggregator);
}

Try / catch

try {
  float v = agg.getFloat();
} catch (UnsupportedOperationException e) {
  log.error("Histogram output is not numeric; use quantile post-aggregator", e);
  throw e;
}

Prevention

When it happens

Trigger: Querying a histogram aggregator's output as a numeric value — e.g. using it directly in a numeric post-aggregator, or selecting it where the engine requests getFloat()/getLong().

Common situations: Legacy histogram usage in queries that apply arithmetic post-aggregators to histogram output; misconfigured post-aggregations assuming numeric results.

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/813988f04a1304fb. Report an issue: GitHub.

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/query/aggregation/HistogramAggregator.java:68

    this.histogram = new Histogram(breaks);
  }

  @Override
  public void aggregate()
  {
    histogram.offer(selector.getFloat());
  }

  @Override
  public Object get()
  {
    return this.histogram;
  }

  @Override
  public float getFloat()
  {
    throw new UnsupportedOperationException("HistogramAggregator does not support getFloat()");
  }

  @Override
  public long getLong()
  {
    throw new UnsupportedOperationException("HistogramAggregator does not support getLong()");
  }

  @Override
  public double getDouble()
  {
    throw new UnsupportedOperationException("HistogramAggregator does not support getDouble()");
  }

  @Override
  public void close()
  {
    // no resources to cleanup

View on GitHub (pinned to 9b90983fd2)