apache/druid · error · IllegalArgumentException

Comparing arrays of estimates and error bounds is not…

Error message

Comparing arrays of estimates and error bounds is not supported

What it means

ArrayOfDoublesSketchToEstimateAndBoundsPostAggregator emits a double[] of an estimate plus lower/upper confidence bounds. There is no defined ordering over such arrays, so getComparator() throws IAE unconditionally to reject sorting on this output.

Solutions

  1. Use ArrayOfDoublesSketchToEstimatePostAggregator (single double value) if you need a sortable estimate
  2. Sort on a different numeric post-aggregator or metric
  3. Do the ordering client-side after receiving the arrays

Example fix

// before
new ArrayOfDoublesSketchToEstimateAndBoundsPostAggregator("eab", "sketch") used in orderBy
// after
new ArrayOfDoublesSketchToEstimatePostAggregator("est", "sketch") used in orderBy
Defensive patterns

Strategy: try-catch

Validate before calling

if (orderByColumns.stream().anyMatch(c -> "estimateAndBounds".equals(c.getDimension()))) {
  throw new IllegalArgumentException("Cannot order by estimate-and-bounds array output");
}

Try / catch

try {
  return queryClient.run(query);
} catch (IllegalArgumentException e) {
  if (e.getMessage() != null && e.getMessage().contains("estimates and error bounds")) {
    return runQueryWithAlternateOrdering(query, "estimate");
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling getComparator(), e.g. when the post-aggregator is referenced in an orderBy spec or a sort-enabled query layer iterates post-aggregators for comparators.

Common situations: Users sorting results by estimate-and-bounds output; generic tooling assuming every post-aggregator provides a comparator.

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

Appendix: source

Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchToEstimateAndBoundsPostAggregator.java:82

  }

  @Override
  public double[] compute(final Map<String, Object> combinedAggregators)
  {
    final ArrayOfDoublesSketch sketch = (ArrayOfDoublesSketch) getField().compute(combinedAggregators);
    return new double[] {sketch.getEstimate(), sketch.getLowerBound(numStdDevs), sketch.getUpperBound(numStdDevs)};
  }

  @Override
  public ColumnType getType(ColumnInspector signature)
  {
    return ColumnType.DOUBLE_ARRAY;
  }

  @Override
  public Comparator<double[]> getComparator()
  {
    throw new IAE("Comparing arrays of estimates and error bounds is not supported");
  }

  @Override
  public String toString()
  {
    return this.getClass().getSimpleName() + "{" +
        "name='" + getName() + '\'' +
        ", field=" + getField() +
        ", numStdDevs=" + numStdDevs +
        "}";
  }

  @Override
  public boolean equals(final Object o)
  {
    if (!super.equals(o)) {
      return false;
    }

View on GitHub (pinned to 9b90983fd2)