apache/druid · error · IllegalArgumentException
Comparing histograms is not supported
Error message
Comparing histograms is not supported
What it means
The KLL sketch to CDF post-aggregator produces a cumulative distribution array of doubles, which has no meaningful ordering. Druid's post-aggregator interface requires getComparator() to be implemented; this class intentionally throws IAE because two histograms/CDFs cannot be compared. It surfaces only if a query tries to order, compare, or use this post-aggregator where a Comparator is required.
Source
Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/kll/KllFloatsSketchToCDFPostAggregator.java:97
return ColumnType.DOUBLE_ARRAY;
}
@JsonProperty
public PostAggregator getField()
{
return field;
}
@JsonProperty
public float[] 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
- Remove any ORDER BY / sort expression that references the CDF post-aggregator output; sort by a scalar column instead.
- If sorting is needed, compute a scalar value (e.g. a specific CDF rank via KLL_SKETCH_TO_QUANTILE) and order on that.
- Do not use this post-aggregator in contexts that require a Comparator (having-clause comparisons, ordered aggregations).
Example fix
// before ... ORDER BY "cdf_output" ASC // after ... ORDER BY "myScalarColumn" ASC
Defensive patterns
Strategy: validation
Validate before calling
if (postAgg instanceof KllFloatsSketchToCDFPostAggregator && requiresComparator(querySpec)) {
throw new IllegalArgumentException("KLL_SKETCH_TO_CDF output is not comparable; do not use in ORDER BY/having");
} Prevention
- Never place array-valued post-aggregators (CDF, histogram, quantiles) in ORDER BY or having clauses.
- Order by a scalar quantile expression when a ranking is needed.
- Review generated queries for auto-assigned comparators on post-aggregators.
When it happens
Trigger: Using KLL_SKETCH_TO_CDF as an ORDER BY expression, in a comparison, or anywhere Druid calls PostAggregator.getComparator() (e.g. order-by specs, having clauses referencing the post-aggregator, or nested aggregations that need comparison).
Common situations: Developers write an ORDER BY on the output column computed by the CDF post-aggregator, or build a query generator that automatically assigns comparators to all post-aggregators, unaware that array-valued post-aggregators (CDFs, histograms, quantiles) are not 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
- Comparing histograms is not supported
- Comparing histograms is not supported
- Comparing arrays of quantiles is not supported
- Comparing sketch summaries is not supported
- Comparing histograms is not supported
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/cb5caf3f7bbb2043.
Report an issue: GitHub.