{"record":{"id":"97e58d4ce4eaed6a","repo":"apache/druid","slug":"histogrambufferaggregator-does-not-support-getdoub","errorCode":null,"errorMessage":"HistogramBufferAggregator does not support getDouble","messagePattern":"HistogramBufferAggregator does not support getDouble","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/query/aggregation/HistogramBufferAggregator.java","lineNumber":105,"sourceCode":"    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\n  }\n\n  @Override\n  public void inspectRuntimeShape(RuntimeShapeInspector inspector)\n  {\n    inspector.visit(\"selector\", selector);\n  }\n}\n","sourceCodeStart":87,"sourceCodeEnd":120,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/query/aggregation/HistogramBufferAggregator.java#L87-L120","documentation":"HistogramBufferAggregator.getDouble() throws UnsupportedOperationException (note the message omits the trailing parentheses) because a histogram aggregate cannot be reduced to one double. The BufferAggregator interface provides getDouble(), but this implementation intentionally rejects it. The error means DOUBLE access was requested on a histogram metric in a buffer-based query path.","triggerScenarios":"A buffer-based query (groupBy/timeseries) with a 'histogram' aggregator whose metric is read via getDouble(ByteBuffer, int); DOUBLE coercion in SQL; double-typed post-aggregators (arithmetic, doubleMean, doubleGreatest) referencing the histogram column.","commonSituations":"Replacing a doubleSum metric with histogram while keeping downstream DOUBLE accessors; SQL queries where Calcite infers DOUBLE for the output; generic result-extraction code that always calls getDouble(); analytics dashboards expecting numeric metrics from histogram aggregators.","solutions":["Read the result with get(ByteBuffer, int) and use the returned Histogram object.","Switch to a double-producing aggregator (doubleSum, doubleMean) if a DOUBLE output is needed.","Remove double-typed post-aggregators/casts from the histogram metric in the query spec.","Harden result-extraction code to detect non-numeric aggregators and use object access instead."],"exampleFix":"// before\ndouble d = bufferAgg.getDouble(buf, position); // throws\n// after\nObject val = bufferAgg.get(buf, position);\ndouble min = (val instanceof Histogram) ? ((Histogram) val).min : Double.NaN;","handlingStrategy":"type-guard","validationCode":"if (bufferAggregator instanceof HistogramBufferAggregator) {\n  // use get(buf, position) (Histogram), not getDouble()\n}","typeGuard":"boolean supportsDouble(BufferAggregator agg) {\n  return !(agg instanceof HistogramBufferAggregator);\n}","tryCatchPattern":"try {\n  value = agg.getDouble(buf, position);\n} catch (UnsupportedOperationException e) {\n  Histogram h = (Histogram) agg.get(buf, position);\n}","preventionTips":["Avoid DOUBLE casts and double post-aggregators over histogram metrics","Verify metric output types (AggregatorFactory.getType()) before result extraction","Treat histogram results as Histogram objects, not scalars","Document aggregator output types in query-building code to prevent mismatched accessors"],"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"}