{"record":{"id":"5d3cfdc557885f76","repo":"apache/druid","slug":"histogrambufferaggregator-does-not-support-getfloa","errorCode":null,"errorMessage":"HistogramBufferAggregator does not support getFloat()","messagePattern":"HistogramBufferAggregator does not support getFloat\\(\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/query/aggregation/HistogramBufferAggregator.java","lineNumber":93,"sourceCode":"  }\n\n  @Override\n  public Object get(ByteBuffer buf, int position)\n  {\n    long[] bins = new long[breaks.length + 1];\n    ByteBuffer mutationBuffer = buf.duplicate();\n    mutationBuffer.position(position);\n    mutationBuffer.asLongBuffer().get(bins);\n\n    float min = mutationBuffer.getFloat(position + minOffset);\n    float max = mutationBuffer.getFloat(position + maxOffset);\n    return new Histogram(breaks, bins, min, max);\n  }\n\n  @Override\n  public float getFloat(ByteBuffer buf, int position)\n  {\n    throw new UnsupportedOperationException(\"HistogramBufferAggregator does not support getFloat()\");\n  }\n\n  @Override\n  public long getLong(ByteBuffer buf, int position)\n  {\n    throw new UnsupportedOperationException(\"HistogramBufferAggregator does not support getLong()\");\n  }\n\n  @Override\n  public double getDouble(ByteBuffer buf, int position)\n  {\n    throw new UnsupportedOperationException(\"HistogramBufferAggregator does not support getDouble\");\n  }\n\n  @Override\n  public void close()\n  {\n    // no resources to cleanup","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/query/aggregation/HistogramBufferAggregator.java#L75-L111","documentation":"HistogramBufferAggregator is the off-heap (ByteBuffer-based) variant of the histogram aggregator in Druid. Its getFloat() is intentionally unimplemented: a histogram aggregate cannot be represented as a single float, so the method throws UnsupportedOperationException. The error indicates the query framework attempted float-valued access on a histogram metric.","triggerScenarios":"A native query using a 'histogram' aggregator is executed in a buffer-based engine path (groupBy/older timeseries) where the metric is retrieved via BufferAggregator.getFloat(); e.g. a float-typed post-aggregator or FLOAT coercion applied to the histogram column.","commonSituations":"FLOAT-typed SQL aggregation over a histogram column; post-aggregator chains that default to float accessors; custom engine code calling getFloat() on buffer aggregators without checking the aggregator type; queries written for numeric aggregators retargeted to histogram.","solutions":["Retrieve the histogram result via get(ByteBuffer, int), which returns the Histogram object.","Use a float-producing aggregator (floatSum, doubleSum) instead of histogram when a FLOAT output is needed.","Remove FLOAT coercion/post-aggregators from the histogram metric in the query spec.","If histogram statistics are needed, finalize the histogram and aggregate over its bins downstream."],"exampleFix":"// before\nfloat f = bufferAgg.getFloat(buf, position); // throws\n// after\nObject val = bufferAgg.get(buf, position);\nHistogram hist = (Histogram) val;","handlingStrategy":"type-guard","validationCode":"if (bufferAggregator instanceof HistogramBufferAggregator) {\n  // must use get(buf, position); never call getFloat()\n}","typeGuard":"boolean supportsFloat(BufferAggregator agg) {\n  return !(agg instanceof HistogramBufferAggregator);\n}","tryCatchPattern":"try {\n  value = agg.getFloat(buf, position);\n} catch (UnsupportedOperationException e) {\n  Object h = agg.get(buf, position);\n}","preventionTips":["Branch on aggregator type before calling primitive getters on buffer aggregators","Keep FLOAT post-aggregators away from histogram metrics","Validate the query spec's metric types at plan time","Use get(ByteBuffer,int) for object-typed aggregators"],"tags":["druid","aggregation","unsupported-operation","buffer-aggregator"],"backgroundTag":"unsupported-operation","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}