apache/druid · error · java.lang.UnsupportedOperationException

Not implemented

Error message

Not implemented

What it means

SketchAggregator (theta sketches) only supports get() returning the sketch object and getDouble(); getFloat is intentionally unimplemented and throws UnsupportedOperationException. Theta sketches are binary objects, not float values, so a float read is meaningless.

Source

Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/theta/SketchAggregator.java:113

  public Object get()
  {
    if (union == null) {
      return SketchHolder.EMPTY;
    }
    //in the code below, I am returning SetOp.getResult(true, null)
    //"true" returns an ordered sketch but slower to compute than unordered sketch.
    //however, advantage of ordered sketch is that they are faster to "union" later
    //given that results from the aggregator will be combined further, it is better
    //to return the ordered sketch here
    synchronized (this) {
      return SketchHolder.of(union.getResult(true, null));
    }
  }

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

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

  @Override
  public double getDouble()
  {
    throw new UnsupportedOperationException("Not implemented");
  }

  @Override
  public void close()
  {
    union = null;

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Call get() and use sketch post-aggregators instead of float access
  2. Change the declared output type to object/DOUBLE as appropriate
  3. Use sketchEstimate post-aggregator to get a numeric estimate rather than float access

Example fix

// before
{"type":"float","fieldName":"sketch"} // output type
// after
{"type":"sketchEstimate","field":{"type":"thetaSketch","fieldName":"sketch"}}
Defensive patterns

Strategy: validation

Validate before calling

if (agg instanceof SketchAggregator && "float".equals(outputType)) { throw new IllegalArgumentException("thetaSketch does not support FLOAT output; use sketchEstimate post-aggregator"); }

Type guard

boolean isThetaNumericReadable(Aggregator a) { return !(a instanceof SketchAggregator); }

Try / catch

try { f = agg.getFloat(); } catch (UnsupportedOperationException e) { f = (float)((Sketch) agg.get()).getEstimate(); }

Prevention

When it happens

Trigger: A theta sketch aggregation (e.g. sketchMerge) is accessed via a FLOAT output type or float post-aggregator; generic aggregator iteration calls getFloat().

Common situations: Declaring outputType FLOAT for a theta sketch metric; third-party query tools that call getFloat on all aggregators; miswritten post-aggregators over sketch columns.

Related errors


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