apache/druid · error · java.lang.UnsupportedOperationException

ApproximateHistogramFoldingAggregator does not support getDo

Error message

ApproximateHistogramFoldingAggregator does not support getDouble()

What it means

ApproximateHistogramFoldingAggregator.getDouble() is intentionally unimplemented because the aggregation result is an ApproximateHistogram, not a double. The method unconditionally throws UnsupportedOperationException; numeric results must come from histogram post-aggregators.

Source

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

    return histogram;
  }

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

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

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

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

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Use quantile/min/max/custom histogram post-aggregators to obtain double values.
  2. Use doubleSum/doubleMin/doubleMax on the raw column if the histogram is not actually needed.
  3. Catch UnsupportedOperationException in generic code and handle non-numeric aggregators explicitly.

Example fix

// before
double v = foldingAggregator.getDouble();
// after
// query JSON:
// {"type": "quantiles", "fieldName": "histFold", "probabilities": [0.5, 0.95]}
double v = quantilesResult[0];
Defensive patterns

Strategy: validation

Validate before calling

// Guard getDouble on folding aggregators:
if (aggregator instanceof org.apache.druid.query.aggregation.histogram.ApproximateHistogramFoldingAggregator) {
  // unsupported; use quantile/min/max post-aggregators
}

Type guard

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

Try / catch

try {
  value = aggregator.getDouble();
} catch (UnsupportedOperationException e) {
  value = histogramQuantile(aggregator.get(), 0.5);
}

Prevention

When it happens

Trigger: Calling ApproximateHistogramFoldingAggregator.getDouble(), or running a query whose result accessor invokes getDouble on an approxHistogramFold aggregation.

Common situations: Queries expecting double output from all aggregators; generic result-extraction loops; misconfigured queries where a double metric column was replaced by a histogram fold.

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/33556080185fe6e8. Report an issue: GitHub.