apache/druid · error · org.apache.druid.java.util.common.IAE
Comparing histograms is not supported
Error message
Comparing histograms is not supported
What it means
Like the CDF post-aggregator, the histogram output (double[]) has no defined total ordering, so DoublesSketchToHistogramPostAggregator.getComparator() always throws IllegalArgumentException('Comparing histograms is not supported'). Reaching it means the engine tried to sort or compare results by the histogram column.
Solutions
- Sort by a scalar post-aggregator (e.g. a quantile) on the same sketch instead of the histogram.
- Remove the sorting reference to the histogram column entirely.
- Fetch unsorted rows and sort client-side if needed.
Example fix
// before
{"queryType":"groupBy","limitSpec":{"columns":[{"dimension":"hist"}]}} // throws
// after
{"queryType":"groupBy","limitSpec":{"columns":[{"dimension":"q50"}]}} // scalar post-agg Defensive patterns
Strategy: validation
Validate before calling
if (sortColumns.stream().anyMatch(histogramPostAggNames::contains)) { throw new IllegalArgumentException("Cannot sort by histogram post-aggregator output"); } Try / catch
try { druidClient.run(query); } catch (IllegalArgumentException e) { if (e.getMessage().contains("Comparing histograms")) { /* remove sorting reference and rerun */ } } Prevention
- Treat double[] post-agg outputs (CDF, histogram, quantiles) as non-sortable.
- Use quantile post-aggs for sort keys.
When it happens
Trigger: Using the histogram post-aggregator's output as an ORDER BY key, topN metric, or limit-spec sorting column in a native query.
Common situations: ORDER BY on a histogram column in SQL, topN with the histogram as metric, or groupBy limit spec sorting on the histogram.
Related errors
- Comparing arrays of quantiles is not supported
- Comparing histograms is not supported
- Comparing sketch summaries is not supported
- Comparing arrays of estimate values is not supported
- Comparing arrays of estimates and error bounds is not…
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/92c1d22c79f386a4.
Report an issue: GitHub.
Appendix: source
Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchToHistogramPostAggregator.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)