apache/druid · error · IllegalArgumentException

Comparing histograms is not supported

Error message

Comparing histograms is not supported

What it means

KllDoublesSketchToCDFPostAggregator.getComparator always throws IllegalArgumentException because a CDF (cumulative distribution function) histogram array has no meaningful total ordering. This comparator is only requested by machinery that needs to order post-aggregator values (e.g. ORDER BY on this output), which the library deliberately refuses to support.

Source

Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/kll/KllDoublesSketchToCDFPostAggregator.java:97

    return ColumnType.DOUBLE_ARRAY;
  }

  @JsonProperty
  public PostAggregator getField()
  {
    return field;
  }

  @JsonProperty
  public double[] getSplitPoints()
  {
    return splitPoints;
  }

  @Override
  public Comparator<double[]> getComparator()
  {
    throw new IAE("Comparing histograms is not supported");
  }

  @Override
  public Set<String> getDependentFields()
  {
    return field.getDependentFields();
  }

  @Override
  public String toString()
  {
    return getClass().getSimpleName() + "{" +
        "name='" + name + '\'' +
        ", field=" + field +
        ", splitPoints=" + Arrays.toString(splitPoints) +
        "}";
  }

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Do not ORDER BY or sort on the CDF output; sort by a scalar field instead
  2. Sort on an intermediate scalar (e.g. a quantile via kllDoublesSketchToQuantiles) rather than the histogram array
  3. If generic code calls getComparator, guard for post-aggregators that don't support comparison before invoking

Example fix

// before
ORDER BY cdfOutput ASC
// after
ORDER BY myQuantile ASC  -- scalar derived via kllDoublesSketchToQuantiles
Defensive patterns

Strategy: validation

Validate before calling

if (postAgg instanceof KllDoublesSketchToCDFPostAggregator) {
  throw new IllegalArgumentException("CDF output is not sortable");
}

Try / catch

try { cmp = postAgg.getComparator(); } catch (IllegalArgumentException e) { cmp = null; /* mark column unsortable */ }

Prevention

When it happens

Trigger: Requesting ordering/comparison semantics on the CDF post-aggregator, e.g. using its output in an ORDER BY, or registering it where a Comparator<double[]> must be supplied by the post-aggregator interface.

Common situations: Trying to sort query results by the CDF output column; UI or API code that generically calls getComparator() on every post-aggregator to build ordering.

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