apache/druid · error · IllegalArgumentException
Comparing histograms is not supported
Error message
Comparing histograms is not supported
What it means
KllDoublesSketchToHistogramPostAggregator.getComparator always throws IllegalArgumentException because a histogram (array of bin counts) has no defined ordering. The post-aggregator interface requires a comparator, but comparing histograms is intentionally unsupported.
Source
Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/kll/KllDoublesSketchToHistogramPostAggregator.java:155
@JsonProperty
@JsonInclude(JsonInclude.Include.NON_NULL)
public double[] 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
- Do not sort on the histogram output; sort by a scalar such as a quantile or the underlying metric
- Compute a single statistic (e.g. kllDoublesSketchToQuantiles with a fraction) and order by that
- Guard generic code: check whether the post-aggregator supports comparison before calling getComparator
Example fix
// before ORDER BY histogramOutput // after ORDER BY median -- from kllDoublesSketchToQuantiles with fraction 0.5
Defensive patterns
Strategy: validation
Validate before calling
if (postAgg instanceof KllDoublesSketchToHistogramPostAggregator) {
throw new IllegalArgumentException("Histogram output is not sortable");
} Try / catch
try { cmp = postAgg.getComparator(); } catch (IllegalArgumentException e) { cmp = null; /* disable sorting for this column */ } Prevention
- Order by scalar statistics (quantiles, medians) instead of histograms
- Keep array-valued outputs out of ORDER BY clauses
- Handle comparator-throwing post-aggregators gracefully in frameworks
When it happens
Trigger: Any code path that requests ordering of this post-aggregator's output, e.g. ORDER BY on the histogram column, or framework code that calls getComparator() to sort results.
Common situations: Sorting query output by the histogram column; generic post-aggregator processing that assumes every comparator is valid; building derived queries that order on array-valued post-aggregators.
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
- Comparing histograms is not supported
- Comparing arrays of quantiles is not supported
- Comparing sketch summaries is not supported
- Comparing histograms is not supported
- Comparing histograms is not supported
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/e11b13d3c438e662.
Report an issue: GitHub.