apache/druid · error · java.lang.UnsupportedOperationException

HyperUniquesBufferAggregator does not support getDouble()

Error message

HyperUniquesBufferAggregator does not support getDouble()

What it means

Companion to the getLong() stub: HyperUniquesBufferAggregator accumulates HLL sketches in ByteBuffer state and cannot produce a double, so getDouble() throws UnsupportedOperationException unconditionally. The only supported extraction is the complex HyperLogLogCollector via get()/getComplexBufferAggregator-style accessors.

Solutions

  1. Use HyperUniqueFinalizingPostAggregator or a sketch-specific finalizer to obtain the estimate instead of getDouble().
  2. Cast/inspect the aggregator type before invoking numeric accessors in custom code.
  3. Switch the metric to a numeric aggregator if a raw double is truly what is needed.

Example fix

// before
double d = agg.getDouble(buf, pos);
// after
Object sketch = agg.get(buf, pos);
double d = ((HyperLogLogCollector) sketch).estimate().doubleValue();
Defensive patterns

Strategy: type-guard

Validate before calling

if (aggregator instanceof HyperUniquesBufferAggregator) { throw new IllegalStateException("hyperUnique aggregator supports no getDouble(); finalize via HyperUniqueFinalizingPostAggregator"); }

Type guard

boolean isHyperUniqueBufferAgg(Aggregator a) { return a instanceof HyperUniquesBufferAggregator; }

Try / catch

try { return agg.getDouble(buf, pos); } catch (UnsupportedOperationException e) { return ((HyperLogLogCollector) agg.get(buf, pos)).estimate().doubleValue(); }

Prevention

When it happens

Trigger: Calling getDouble(ByteBuffer, int) on a hyperUnique buffer aggregator — typically from a double-typed post-aggregator or a numeric column-processor iterating over a sketch-typed metric.

Common situations: Same family as 1350: custom post-aggregation over uniques metrics, engines or tooling assuming all aggregators yield doubles/longs, incorrect query layer choosing numeric finalization for a complex metric.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/query/aggregation/hyperloglog/HyperUniquesBufferAggregator.java:112

  }

  @Override
  public float getFloat(ByteBuffer buf, int position)
  {
    throw new UnsupportedOperationException("HyperUniquesBufferAggregator does not support getFloat()");
  }


  @Override
  public long getLong(ByteBuffer buf, int position)
  {
    throw new UnsupportedOperationException("HyperUniquesBufferAggregator does not support getLong()");
  }

  @Override
  public double getDouble(ByteBuffer buf, int position)
  {
    throw new UnsupportedOperationException("HyperUniquesBufferAggregator does not support getDouble()");
  }

  @Override
  public void close()
  {
    // no resources to cleanup
  }

  @Override
  public void inspectRuntimeShape(RuntimeShapeInspector inspector)
  {
    inspector.visit("selector", selector);
  }
}

View on GitHub (pinned to 9b90983fd2)