apache/druid · error · IAE
Comparing arrays of estimates and error bounds is not suppor
Error message
Comparing arrays of estimates and error bounds is not supported
What it means
HllSketchToEstimateWithBoundsPostAggregator outputs double[] (estimate plus upper/lower bounds), and since arrays of estimates+bounds have no meaningful ordering, getComparator() always throws IllegalArgumentException. This post-aggregator cannot be used where comparability is required, e.g. as the field of an orderBy/sorting or comparator-consuming aggregator.
Source
Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/hll/HllSketchToEstimateWithBoundsPostAggregator.java:100
return field;
}
@JsonProperty
public int getNumStdDev()
{
return numStdDevs;
}
@Override
public Set<String> getDependentFields()
{
return field.getDependentFields();
}
@Override
public Comparator<double[]> getComparator()
{
throw new IAE("Comparing arrays of estimates and error bounds is not supported");
}
@Override
public double[] compute(final Map<String, Object> combinedAggregators)
{
Object hllSketchHolderObject = field.compute(combinedAggregators);
if (hllSketchHolderObject == null) {
return new double[] {0.0D, 0.0D, 0.0D};
}
final HllSketchHolder sketch = HllSketchHolder.fromObj(hllSketchHolderObject);
return new double[] {sketch.getEstimate(), sketch.getLowerBound(numStdDevs), sketch.getUpperBound(numStdDevs)};
}
@Override
public PostAggregator decorate(final Map<String, AggregatorFactory> aggregators)
{
return this;
}View on GitHub (pinned to 9b90983fd2)
Solutions
- Use HllSketchToEstimatePostAggregator (double estimate) where sorting/comparison is needed
- Sort by a scalar projection (the estimate) rather than the double[] bounds array
- If bounds are needed, output them as separate columns and sort by the estimate column
Example fix
// before
postAggs.add(new HllSketchToEstimateWithBoundsPostAggregator("est", field, 2));
query.orderBy("est")
// after
postAggs.add(new HllSketchToEstimatePostAggregator("est", field));
query.orderBy("est") Defensive patterns
Strategy: validation
Validate before calling
if (postAgg instanceof HllSketchToEstimateWithBoundsPostAggregator) { throw new IllegalArgumentException("estimate-with-bounds output is not comparable; use HllSketchToEstimatePostAggregator for sorting"); } Try / catch
try { cmp = postAgg.getComparator(); } catch (IllegalArgumentException e) { cmp = Comparator.comparingDouble(a -> ((double[]) a)[0]); } // compare by estimate only Prevention
- Never place estimate-with-bounds post-aggs in orderBy/having
- Use HllSketchToEstimatePostAggregator for comparable output
- Treat double[] bounds as display-only data
When it happens
Trigger: Using HllSketchToEstimateWithBounds (estimate+bounds output) inside an ORDER BY / having spec, or feeding it into another post-aggregator that calls getComparator() (e.g. arithmetic or comparative post-aggs).
Common situations: Users trying to sort query results by estimate-with-bounds; wrapping the bounds post-agg in a greatest/least or comparison post-aggregator; streaming frameworks requesting a comparator for the post-aggregated column.
Related errors
- Comparing histograms is not supported
- Comparing histograms is not supported
- Comparing arrays of quantiles is not supported
- Comparing sketch summaries is not supported
- Comparing histograms is not supported
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/13dfb37a3faff382.
Report an issue: GitHub.