apache/druid · error · UnsupportedOperationException

Not implemented

Error message

Not implemented

What it means

HllSketchBuildAggregator.getFloat unconditionally throws UnsupportedOperationException because an HLL sketch aggregator produces a sketch (complex object), not a numeric value. Druid calls getFloat only when a query coerces this aggregator's result to a FLOAT, which is meaningless for HLL sketches.

Source

Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/hll/HllSketchBuildAggregator.java:76

   * and Druid can call aggregate() and get() concurrently.
   * See https://github.com/druid-io/druid/pull/3956
   */
  @Override
  public synchronized Object get()
  {
    return HllSketchHolder.of(sketch.copy());
  }

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

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

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

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Don't treat the HLL sketch as a number; use HLLSketchMerge or HLLSketchToString post-aggregators instead.
  2. To get counts, wrap with HLLSketchToCount (+/-) post-aggregator or use APPROX_COUNT_DISTINCT_DS_HLL in SQL.
  3. If you meant a numeric aggregate, switch to the appropriate aggregator (floatSum/longSum) or the correct input column type.

Example fix

// before
{"type": "HLLSketchBuild", "name": "s", "fieldName": "v"}, {"type": "arithmetic", "fn": "+", "fields": ["s"]}
// after
{"type": "HLLSketchBuild", "name": "s", "fieldName": "v"}, {"type": "HLLSketchToCount", "name": "cnt", "field": "s"}
Defensive patterns

Strategy: validation

Validate before calling

if (aggregatorFactory.getType().startsWith("HLLSketch")) { // must finalize via sketch post-aggregator, not numeric access }

Type guard

boolean isNumericAggregator = agg.getType() instanceof String t && !t.contains("Sketch");

Try / catch

try { float f = aggregator.getFloat(); } catch (UnsupportedOperationException e) { /* use HLLSketchToCount post-aggregator instead */ }

Prevention

When it happens

Trigger: A Druid query requests the HllSketchBuild aggregator's result as a float, e.g. applying numeric post-aggregators or arithmetic to an HLL_SKETCH build aggregator, or selecting it with an output type of FLOAT.

Common situations: Writing SQL like AVG over an HLL sketch column, wrapping the sketch aggregator in a arithmetic post-aggregator, or changing a native query's aggregator output type from 'HLLSketch' to float.

Related errors


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