{"record":{"id":"33556080185fe6e8","repo":"apache/druid","slug":"approximatehistogramfoldingaggregator-does-not-sup-335560","errorCode":null,"errorMessage":"ApproximateHistogramFoldingAggregator does not support getDouble()","messagePattern":"ApproximateHistogramFoldingAggregator 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/ApproximateHistogramFoldingAggregator.java","lineNumber":84,"sourceCode":"    return histogram;\n  }\n\n  @Override\n  public float getFloat()\n  {\n    throw new UnsupportedOperationException(\"ApproximateHistogramFoldingAggregator does not support getFloat()\");\n  }\n\n  @Override\n  public long getLong()\n  {\n    throw new UnsupportedOperationException(\"ApproximateHistogramFoldingAggregator does not support getLong()\");\n  }\n\n  @Override\n  public double getDouble()\n  {\n    throw new UnsupportedOperationException(\"ApproximateHistogramFoldingAggregator does not support getDouble()\");\n  }\n\n  @Override\n  public void close()\n  {\n    // no resources to cleanup\n  }\n}\n","sourceCodeStart":66,"sourceCodeEnd":93,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/ApproximateHistogramFoldingAggregator.java#L66-L93","documentation":"ApproximateHistogramFoldingAggregator.getDouble() is intentionally unimplemented because the aggregation result is an ApproximateHistogram, not a double. The method unconditionally throws UnsupportedOperationException; numeric results must come from histogram post-aggregators.","triggerScenarios":"Calling ApproximateHistogramFoldingAggregator.getDouble(), or running a query whose result accessor invokes getDouble on an approxHistogramFold aggregation.","commonSituations":"Queries expecting double output from all aggregators; generic result-extraction loops; misconfigured queries where a double metric column was replaced by a histogram fold.","solutions":["Use quantile/min/max/custom histogram post-aggregators to obtain double values.","Use doubleSum/doubleMin/doubleMax on the raw column if the histogram is not actually needed.","Catch UnsupportedOperationException in generic code and handle non-numeric aggregators explicitly."],"exampleFix":"// before\ndouble v = foldingAggregator.getDouble();\n// after\n// query JSON:\n// {\"type\": \"quantiles\", \"fieldName\": \"histFold\", \"probabilities\": [0.5, 0.95]}\ndouble v = quantilesResult[0];","handlingStrategy":"validation","validationCode":"// Guard getDouble on folding aggregators:\nif (aggregator instanceof org.apache.druid.query.aggregation.histogram.ApproximateHistogramFoldingAggregator) {\n  // unsupported; use quantile/min/max post-aggregators\n}","typeGuard":"boolean supportsDouble(Object agg) {\n  return !(agg instanceof org.apache.druid.query.aggregation.histogram.ApproximateHistogramFoldingAggregator);\n}","tryCatchPattern":"try {\n  value = aggregator.getDouble();\n} catch (UnsupportedOperationException e) {\n  value = histogramQuantile(aggregator.get(), 0.5);\n}","preventionTips":["Review query specs so histogram folds always feed histogram post-aggs.","Search query templates for direct accessor calls on approxHistogramFold fields.","Fail fast in custom engines when an aggregator type lacks numeric 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-14T05:17:10.506Z"}