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
DoublesSketchToCDFPostAggregator produces a cumulative distribution histogram (double[]). Druid's PostAggregator contract requires getComparator() for sorting/comparing results, but comparing two CDF arrays has no meaningful ordering, so the implementation always throws IllegalArgumentException('Comparing histograms is not supported').
Solutions
- Remove the ORDER BY / topN metric reference on the CDF post-aggregator; sort by the underlying doublesSketch aggregation's scalar post-agg or another scalar column instead.
- Sort by an accompanying scalar post-aggregator (e.g. quantile) derived from the same sketch.
- Do client-side sorting after retrieving rows.
Example fix
// before
{"queryType":"topN","metric":"myCdf", ...} // throws
// after
{"queryType":"topN","metric":"myQuantile", // scalar post-agg on same sketch
"postAggregators":[{"type":"quantilesDoublesSketchToQuantiles", ...}]} Defensive patterns
Strategy: validation
Validate before calling
if (query.getOrderBy() != null && query.getOrderBy().contains("cdfPostAgg")) { throw new IllegalArgumentException("Cannot order by DoublesSketchToCDF output"); } Try / catch
try { druidClient.run(query); } catch (IllegalArgumentException e) { if (e.getMessage().contains("Comparing histograms")) { /* strip ORDER BY on CDF and rerun */ } } Prevention
- Never reference array-valued post-aggregators in ORDER BY/topN metrics.
- Order by scalar quantile post-aggs derived from the same sketch.
When it happens
Trigger: Using DoublesSketchToCDFPostAggregator in any context where the engine requests its comparator: ORDER BY on the post-aggregator output, topN metric on it, or sorting via having/limit specs that compare the column.
Common situations: Trying to ORDER BY a CDF/histogram column in SQL or native topN, or using the histogram as a sorting metric in a groupBy limit spec.
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/b08c60de13a38335.
Report an issue: GitHub.
Appendix: source
Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchToCDFPostAggregator.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)