apache/druid · error · IllegalArgumentException

Comparing histograms is not supported

Error message

Comparing histograms is not supported

What it means

Like the CDF post-aggregator, the histogram post-aggregator outputs an array of doubles that cannot be meaningfully ordered, so getComparator() deliberately throws IAE. Druid requires a comparator only when the post-aggregator is used in an ordering or comparison context.

Source

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

  @JsonProperty
  @JsonInclude(JsonInclude.Include.NON_NULL)
  public float[] getSplitPoints()
  {
    return splitPoints;
  }

  @JsonProperty
  @JsonInclude(JsonInclude.Include.NON_NULL)
  public Integer getNumBins()
  {
    return numBins;
  }

  @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) +
        ", numBins=" + numBins +
        "}";
  }

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Sort by a scalar column or expression instead of the histogram output.
  2. Extract a scalar (e.g. a quantile via KLL_SKETCH_TO_QUANTILE) and order on that.
  3. Avoid using this post-aggregator in comparator-requiring contexts such as order-by specs.

Example fix

// before
... ORDER BY "histogram_output"

// after
... ORDER BY "histogram_output[0]" -- or a scalar quantile expression
Defensive patterns

Strategy: validation

Validate before calling

if (postAgg instanceof KllFloatsSketchToHistogramPostAggregator && requiresComparator(querySpec)) {
  throw new IllegalArgumentException("Histogram output is not comparable; use a scalar expression for ordering");
}

Prevention

When it happens

Trigger: Using KLL_SKETCH_TO_HISTOGRAM output in ORDER BY, in a having/filter comparison, or in any code path that calls PostAggregator.getComparator() on this object.

Common situations: Ordering query results by a histogram column, or generic query tooling that assumes every post-aggregator is comparable.

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