{"record":{"id":"813988f04a1304fb","repo":"apache/druid","slug":"histogramaggregator-does-not-support-getfloat","errorCode":null,"errorMessage":"HistogramAggregator does not support getFloat()","messagePattern":"HistogramAggregator does not support getFloat\\(\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/query/aggregation/HistogramAggregator.java","lineNumber":68,"sourceCode":"    this.histogram = new Histogram(breaks);\n  }\n\n  @Override\n  public void aggregate()\n  {\n    histogram.offer(selector.getFloat());\n  }\n\n  @Override\n  public Object get()\n  {\n    return this.histogram;\n  }\n\n  @Override\n  public float getFloat()\n  {\n    throw new UnsupportedOperationException(\"HistogramAggregator does not support getFloat()\");\n  }\n\n  @Override\n  public long getLong()\n  {\n    throw new UnsupportedOperationException(\"HistogramAggregator does not support getLong()\");\n  }\n\n  @Override\n  public double getDouble()\n  {\n    throw new UnsupportedOperationException(\"HistogramAggregator does not support getDouble()\");\n  }\n\n  @Override\n  public void close()\n  {\n    // no resources to cleanup","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/query/aggregation/HistogramAggregator.java#L50-L86","documentation":"HistogramAggregator accumulates a floating-point histogram and exposes getComplexValue()/get(); numeric accessors getFloat()/getLong() are intentionally unsupported and throw UnsupportedOperationException because a histogram is not a scalar number.","triggerScenarios":"Querying a histogram aggregator's output as a numeric value — e.g. using it directly in a numeric post-aggregator, or selecting it where the engine requests getFloat()/getLong().","commonSituations":"Legacy histogram usage in queries that apply arithmetic post-aggregators to histogram output; misconfigured post-aggregations assuming numeric results.","solutions":["Use histogram-specific post-aggregators (e.g. quantile/equalBuckets/CustomBuckets) instead of numeric ones","Do not apply arithmetic/numeric post-aggregators to histogram output","Switch to an approximate quantile aggregator (e.g. DataSketches quantiles) if numeric summaries are needed"],"exampleFix":"// before\nnew ArithmeticPostAggregator(\"q\", \"+\", [fieldAccess(\"hist\")])\n// after\nnew QuantilePostAggregator(\"q\", \"hist\", 0.5)","handlingStrategy":"type-guard","validationCode":"// before numeric post-aggregation\nif (aggregatorType.equals(\"histogram\")) {\n  throw new IllegalArgumentException(\"Use histogram post-aggregators (quantile/equalBuckets) instead of numeric accessors\");\n}","typeGuard":"boolean supportsNumericAccess(Aggregator agg) {\n  return !(agg instanceof HistogramAggregator);\n}","tryCatchPattern":"try {\n  float v = agg.getFloat();\n} catch (UnsupportedOperationException e) {\n  log.error(\"Histogram output is not numeric; use quantile post-aggregator\", e);\n  throw e;\n}","preventionTips":["Never apply arithmetic/numeric post-aggregators to histogram columns","Use quantile/equalBuckets/customBuckets post-aggregators for histogram output","Prefer DataSketches quantiles sketch when numeric summaries are needed"],"tags":["aggregation","unsupported-operation","druid"],"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"}