apache/druid · warning · UnsupportedOperationException

not implemented

Error message

not implemented

What it means

MomentSketchBuildAggregator.getFloat unconditionally throws UnsupportedOperationException because a Moments Sketch is a composite object, not a scalar, so it cannot be converted to a float. This surfaces when a query or post-aggregator requests the sketch aggregation as a FLOAT value instead of reading it via getObject/getComplex.

Source

Thrown at extensions-contrib/momentsketch/src/main/java/org/apache/druid/query/aggregation/momentsketch/aggregator/MomentSketchBuildAggregator.java:65

  @Override
  public void aggregate()
  {
    if (valueSelector.isNull()) {
      return;
    }
    momentsSketch.add(valueSelector.getDouble());
  }

  @Override
  public Object get()
  {
    return momentsSketch;
  }

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

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

  @Override
  public Aggregator clone()
  {
    return new MomentSketchBuildAggregator(valueSelector, k, compress);
  }

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

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Request the sketch as its complex/sketch output type (e.g. no type coercion; use getObject / the sketch post-aggregators) rather than FLOAT.
  2. Remove any post-aggregators or expressions that treat the sketch column as a numeric float.
  3. If a numeric summary is needed, add a dedicated sketch post-aggregator (e.g. quantile/mean) that computes a float from the sketch.
  4. If the sketch is only an intermediate, mark the metric as a COMPLEX aggregator input and aggregate via the factory's merge path.

Example fix

// before
AggregatorFactory agg = new MomentSketchAggregatorFactory("sketch", "value", 50, true);
query.outputType.put("sketch", ValueType.FLOAT); // throws
// after
query.outputType.put("sketch", ValueType.COMPLEX);
PostAggregator mean = new MomentSketchMeanPostAggregator("mean", "sketch");
Defensive patterns

Strategy: type-guard

Validate before calling

// ensure query never requests FLOAT output for sketch aggregators
if (query.getOutputType("sketch") == ValueType.FLOAT) {
  throw new IllegalArgumentException("momentsketch must use COMPLEX output, not FLOAT");
}

Type guard

if (agg instanceof MomentSketchAggregatorFactory) {
  // read via getObject / complex accessor, never getFloat()
}

Try / catch

try {
  return aggregator.getFloat();
} catch (UnsupportedOperationException e) {
  throw new IllegalStateException("Use COMPLEX output / sketch post-aggregators for momentsketch", e);
}

Prevention

When it happens

Trigger: A Druid native query or SQL query selects the momentsketch aggregator with an outputType of FLOAT, or a post-aggregator/expression reads getFloat() on a build aggregator for the sketch metric.

Common situations: Copying a query template that used float aggregations and just swapping in the momentsketch aggregator; SQL planner coercing the column to FLOAT; tooling that introspects all aggregators generically assuming numeric output.

Related errors


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