{"record":{"id":"95b447ca62d31af0","repo":"apache/druid","slug":"approximatehistogramfoldingbufferaggregator-does-n","errorCode":null,"errorMessage":"ApproximateHistogramFoldingBufferAggregator does not support getFloat()","messagePattern":"ApproximateHistogramFoldingBufferAggregator does not support getFloat\\(\\)","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramFoldingBufferAggregator.java","lineNumber":66,"sourceCode":"  }\n\n  @Override\n  public void aggregate(ByteBuffer buf, int position)\n  {\n    ApproximateHistogram hNext = selector.getObject();\n    innerAggregator.aggregate(buf, position, hNext);\n  }\n\n  @Override\n  public Object get(ByteBuffer buf, int position)\n  {\n    return innerAggregator.get(buf, position);\n  }\n\n  @Override\n  public float getFloat(ByteBuffer buf, int position)\n  {\n    throw new UnsupportedOperationException(\"ApproximateHistogramFoldingBufferAggregator does not support getFloat()\");\n  }\n\n  @Override\n  public long getLong(ByteBuffer buf, int position)\n  {\n    throw new UnsupportedOperationException(\"ApproximateHistogramFoldingBufferAggregator does not support getLong()\");\n  }\n\n  @Override\n  public double getDouble(ByteBuffer buf, int position)\n  {\n    throw new UnsupportedOperationException(\"ApproximateHistogramFoldingBufferAggregator does not support getDouble()\");\n  }\n\n  @Override\n  public void close()\n  {\n    // no resources to cleanup","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramFoldingBufferAggregator.java#L48-L84","documentation":"ApproximateHistogramFoldingBufferAggregator folds histograms into a ByteBuffer; getFloat() is intentionally unsupported because the buffered result is a histogram object, not a float. Calling it always throws UnsupportedOperationException. Use post-aggregation to extract numeric statistics from the folded histogram.","triggerScenarios":"Calling ApproximateHistogramFoldingBufferAggregator.getFloat(ByteBuffer, int), or a query engine requesting a float accessor from a buffer-aggregated approxHistogramFold column.","commonSituations":"Generic code iterating all buffer aggregators numerically; queries that treat histogram fold results as float metrics; frameworks auto-selecting float accessors based on column naming conventions.","solutions":["Use histogram post-aggregators (quantile, min, max, etc.) to compute numeric values from the folded histogram.","Aggregate the numeric column directly with a float/double-capable aggregator if the histogram is unnecessary.","Wrap generic accessor calls in a try/catch for UnsupportedOperationException and use object-based access instead."],"exampleFix":"// before\nfloat v = bufferAggregator.getFloat(buf, position);\n// after\n// query JSON:\n// {\"type\": \"quantile\", \"fieldName\": \"histFold\", \"probability\": 0.9}\nfloat v = (float) p90Result;","handlingStrategy":"validation","validationCode":"// Guard buffered fold aggregators before primitive getters:\nif (aggregator instanceof org.apache.druid.query.aggregation.histogram.ApproximateHistogramFoldingBufferAggregator) {\n  // use histogram post-aggregators instead of getFloat()\n}","typeGuard":"boolean supportsFloat(Object agg) {\n  return !(agg instanceof org.apache.druid.query.aggregation.histogram.ApproximateHistogramFoldingBufferAggregator);\n}","tryCatchPattern":"try {\n  value = aggregator.getFloat(buf, position);\n} catch (UnsupportedOperationException e) {\n  value = (float) quantileFromBuffer(buf, position, 0.5);\n}","preventionTips":["Treat approxHistogramFold buffered results as histogram objects only.","Route numeric extraction through post-aggregators defined in the query spec.","Type-check aggregators in generic engines before invoking primitive getters."],"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-17T15:17:12.973Z"}