apache/druid · error · java.lang.UnsupportedOperationException

Not implemented

Error message

Not implemented

What it means

DoublesSketchMergeBufferAggregator.getFloat(ByteBuffer,int) is intentionally left unimplemented: the merged value stored in the buffer is a quantiles DoublesSketch, and extracting it as a float would be invalid, so the method throws UnsupportedOperationException to expose the incorrect accessor usage.

Source

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

    helper.init(buffer, position);
  }

  @Override
  public void aggregate(final ByteBuffer buffer, final int position)
  {
    DoublesSketchMergeAggregator.updateUnion(selector, helper.getSketchAtPosition(buffer, position));
  }

  @Override
  public Object get(final ByteBuffer buffer, final int position)
  {
    return helper.getSketchAtPosition(buffer, position).getResult();
  }

  @Override
  public float getFloat(final ByteBuffer buffer, final int position)
  {
    throw new UnsupportedOperationException("Not implemented");
  }

  @Override
  public long getLong(final ByteBuffer buffer, final int position)
  {
    throw new UnsupportedOperationException("Not implemented");
  }

  @Override
  public synchronized void close()
  {
    helper.clear();
  }

  // A small number of sketches may run out of the given memory, request more memory on heap and move there.
  // In that case we need to reuse the object from the cache as opposed to wrapping the new buffer.
  @Override
  public synchronized void relocate(int oldPosition, int newPosition, ByteBuffer oldBuffer, ByteBuffer newBuffer)

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Use get(buffer, position), which returns the merged sketch (or finalized value) via helper.getSketchAtPosition(...).getResult()
  2. Correct the column signature to TYPE_COMPLEX for sketch columns
  3. Use sketch post-aggregators for numeric metrics derived from the sketch

Example fix

// before
float v = agg.getFloat(buf, position);
// after
Object result = agg.get(buf, position); // merged sketch or finalized value
Defensive patterns

Strategy: type-guard

Validate before calling

Object v = mergeBufferAggregator.get(buffer, position);
if (v instanceof DoublesSketch || v instanceof Number) { /* ok */ } else { throw new IllegalStateException("Unexpected buffer value"); }

Type guard

boolean isComplexSketchSelector(ColumnValueSelector<?> sel) {
  return sel.getObject() instanceof DoublesSketch || sel.getObject() instanceof Number;
}

Try / catch

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

Prevention

When it happens

Trigger: Calling getFloat(buffer, position) on the merge buffer aggregator, e.g. when a query engine's selector signature treats the merged sketch column as a float numeric column.

Common situations: Distributed group-by/broker-side merges where intermediate sketch columns are mis-signed as numeric; custom code reading BufferAggregator results generically.

Related errors


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