apache/druid · error · UnsupportedOperationException

Not implemented

Error message

Not implemented

What it means

DoublesSketchBuildAggregator accumulates a quantiles DoublesSketch, which is only meaningful as a sketch object. Druid's Aggregator interface requires getFloat()/getLong() implementations, but a sketch cannot be losslessly represented as a float, so the implementation deliberately throws UnsupportedOperationException to surface misuse rather than return a silently wrong number.

Source

Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchBuildAggregator.java:61

  @Override
  public synchronized void aggregate()
  {
    if (valueSelector.isNull()) {
      return;
    }
    sketch.update(valueSelector.getDouble());
  }

  @Override
  public synchronized Object get()
  {
    return sketch;
  }

  @Override
  public float getFloat()
  {
    throw new UnsupportedOperationException("Not implemented");
  }

  @Override
  public long getLong()
  {
    throw new UnsupportedOperationException("Not implemented");
  }

  @Override
  public synchronized void close()
  {
    sketch = null;
  }
}

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Use get() instead, which returns the finalized value when shouldFinalize is true, or the sketch object otherwise
  2. Apply a quantilesDoublesSketchToQuantile / -ToHistogram / -ToRank post-aggregator to extract numeric values from the sketch
  3. Set shouldFinalize=true if a numeric result is what the query needs

Example fix

// before
float v = aggregator.getFloat();
// after
Object v = aggregator.get();
double d = ((Number) v).doubleValue(); // when shouldFinalize=true
Defensive patterns

Strategy: type-guard

Validate before calling

Object result = aggregator.get();
if (!(result instanceof Number) && !(result instanceof DoublesSketch)) {
  throw new IllegalStateException("Unexpected sketch aggregator result type: " + result.getClass());
}

Type guard

boolean isFinalizedNumeric(Aggregator agg) {
  return agg.get() instanceof Number; // true only when shouldFinalize=true
}

Try / catch

try {
  return aggregator.getFloat();
} catch (UnsupportedOperationException e) {
  Object v = aggregator.get();
  return v instanceof Number ? ((Number) v).floatValue() : Float.NaN;
}

Prevention

When it happens

Trigger: Calling getFloat() on a build-phase quantilesDoublesSketch aggregator, e.g. configuring post-aggregators or column types that expect a primitive float result from an unfinalized sketch build.

Common situations: Selecting a sketch aggregator column with a numeric column type; custom code that reads aggregator results generically via getFloat; misconfigured post-aggregator arithmetic on a raw sketch column.

Related errors


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