apache/druid · error · org.apache.druid.java.util.common.IAE
Comparing sketch summaries is not supported
Error message
Comparing sketch summaries is not supported
What it means
DoublesSketchToStringPostAggregator outputs a human-readable sketch summary String. Strings could be compared alphabetically, but the summary is diagnostic text whose ordering is meaningless, so getComparator() deliberately throws IllegalArgumentException('Comparing sketch summaries is not supported').
Solutions
- Sort by a scalar post-aggregator (quantile/histogram-derived value) from the same sketch.
- Remove the ORDER BY / metric reference to the string post-aggregator.
- If you just need the summary for display, keep it in postAggregators but exclude it from sorting specs.
Example fix
// before
{"queryType":"topN","metric":"sketchSummary", ...}
// after
{"queryType":"topN","metric":"quantile50", "postAggregators":[{"type":"quantilesDoublesSketchToString",...}]} Defensive patterns
Strategy: validation
Validate before calling
if (sortKeys.contains(toStringPostAggName)) { throw new IllegalArgumentException("Sketch summaries are not sortable"); } Try / catch
try { druidClient.run(query); } catch (IllegalArgumentException e) { if (e.getMessage().contains("Comparing sketch summaries")) { /* drop sort key and rerun */ } } Prevention
- Use the string post-agg only for display/diagnostics.
- Choose numeric post-aggs for ordering.
When it happens
Trigger: Using the string post-aggregator output as an ORDER BY key, topN metric, or sorting column in a limit spec.
Common situations: ORDER BY on the sketch summary column in SQL or native queries; treating the toString output as a sortable dimension.
Related errors
- Comparing arrays of quantiles is not supported
- Comparing histograms is not supported
- Comparing histograms 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/54bbbcdcf9658bf1.
Report an issue: GitHub.
Appendix: source
Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchToStringPostAggregator.java:83
}
@JsonProperty
public PostAggregator getField()
{
return field;
}
@Override
public Object compute(final Map<String, Object> combinedAggregators)
{
final DoublesSketch sketch = (DoublesSketch) field.compute(combinedAggregators);
return sketch.toString();
}
@Override
public Comparator<String> getComparator()
{
throw new IAE("Comparing sketch summaries is not supported");
}
@Override
public byte[] getCacheKey()
{
final CacheKeyBuilder builder = new CacheKeyBuilder(
AggregatorUtil.QUANTILES_DOUBLES_SKETCH_TO_STRING_CACHE_TYPE_ID).appendCacheable(field);
return builder.build();
}
@Override
public PostAggregator decorate(final Map<String, AggregatorFactory> map)
{
return this;
}
@Override
public Set<String> getDependentFields()View on GitHub (pinned to 9b90983fd2)