apache/druid · error · IllegalArgumentException

Comparing sketch summaries is not supported

Error message

Comparing sketch summaries is not supported

What it means

KllDoublesSketchToStringPostAggregator.getComparator always throws IllegalArgumentException because a sketch's string summary is descriptive text, not an ordered value. The method satisfies the post-aggregator interface but comparison is deliberately unsupported.

Source

Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/kll/KllDoublesSketchToStringPostAggregator.java:83

  }

  @JsonProperty
  public PostAggregator getField()
  {
    return field;
  }

  @Override
  public Object compute(final Map<String, Object> combinedAggregators)
  {
    final KllDoublesSketch sketch = (KllDoublesSketch) 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(
        PostAggregatorIds.KLL_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)

Solutions

  1. Do not ORDER BY on the sketch summary; order by a scalar metric or quantile instead
  2. If text ordering is truly needed, extract the summary client-side and sort in application code
  3. Have generic frameworks treat comparator-throwing post-aggregators as non-sortable

Example fix

// before
ORDER BY sketchSummary
// after
ORDER BY sketchSummary IN CLIENT CODE  -- fetch rows, then sort strings in the app
Defensive patterns

Strategy: validation

Validate before calling

if (postAgg instanceof KllDoublesSketchToStringPostAggregator) {
  throw new IllegalArgumentException("Sketch summary output is not sortable");
}

Try / catch

try { cmp = postAgg.getComparator(); } catch (IllegalArgumentException e) { cmp = null; }

Prevention

When it happens

Trigger: Requesting ordering on the string output of kllDoublesSketchToString, e.g. ORDER BY on the summary column, or framework code calling getComparator() for sorting.

Common situations: Sorting results by sketch summary text; generic result-table sorting in UI over string post-aggregator columns; SQL ORDER BY on the summary output.

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


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/f4be4ac19f8398c3. Report an issue: GitHub.