{"record":{"id":"cef78cc66045ed6b","repo":"apache/druid","slug":"approximatehistogrambufferaggregator-does-not-supp-cef78c","errorCode":null,"errorMessage":"ApproximateHistogramBufferAggregator does not support getDouble()","messagePattern":"ApproximateHistogramBufferAggregator does not support getDouble\\(\\)","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramBufferAggregator.java","lineNumber":76,"sourceCode":"  }\n\n  @Override\n  public float getFloat(ByteBuffer buf, int position)\n  {\n    throw new UnsupportedOperationException(\"ApproximateHistogramBufferAggregator does not support getFloat()\");\n  }\n\n\n  @Override\n  public long getLong(ByteBuffer buf, int position)\n  {\n    throw new UnsupportedOperationException(\"ApproximateHistogramBufferAggregator does not support getLong()\");\n  }\n\n  @Override\n  public double getDouble(ByteBuffer buf, int position)\n  {\n    throw new UnsupportedOperationException(\"ApproximateHistogramBufferAggregator 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":58,"sourceCodeEnd":91,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramBufferAggregator.java#L58-L91","documentation":"ApproximateHistogramBufferAggregator.getDouble() is deliberately unimplemented because the aggregator's output is an ApproximateHistogram object, not a double. There is no defined double representation of the histogram, so the method throws UnsupportedOperationException unconditionally.","triggerScenarios":"Calling ApproximateHistogramBufferAggregator.getDouble(ByteBuffer, int), or executing a query whose result extraction invokes getDouble on a buffer-aggregated approxHistogram column.","commonSituations":"Queries expecting double metrics from every aggregator; framework code iterating BufferAggregator results numerically; misconfiguring the query so the histogram fold result is read directly as a double.","solutions":["Use histogram-specific post-aggregators (e.g. quantile, quantiles, min, max) to obtain numeric values.","If a plain double metric is needed, use doubleSum/doubleMin/doubleMax on the raw column instead of approxHistogram.","In generic code, check the aggregator's supported types or catch UnsupportedOperationException and fall back to object-based access."],"exampleFix":"// before\ndouble v = bufferAggregator.getDouble(buf, position);\n// after\n// query with histogram post-aggregator:\n// {\"type\": \"min\", \"fieldName\": \"approxHist\"}\ndouble v = minPostAggResult;","handlingStrategy":"validation","validationCode":"// Confirm the aggregator is not histogram-based before getDouble:\nboolean isHistogram = aggregator instanceof org.apache.druid.query.aggregation.histogram.ApproximateHistogramBufferAggregator;\nif (!isHistogram) { value = aggregator.getDouble(buf, position); }","typeGuard":"boolean supportsDouble(Object agg) {\n  return !(agg instanceof org.apache.druid.query.aggregation.histogram.ApproximateHistogramBufferAggregator);\n}","tryCatchPattern":"try {\n  value = aggregator.getDouble(buf, position);\n} catch (UnsupportedOperationException e) {\n  value = quantilePostAgg(buf, position);\n}","preventionTips":["Use doubleSum/doubleMin/doubleMax when a double output is required, not approxHistogram.","Pair every histogram aggregation with a histogram post-aggregator.","Avoid generic loops that call getDouble on arbitrary aggregators."],"tags":["java","druid","aggregation","unsupported-operation"],"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"}