{"record":{"id":"8620c3e4c3104d26","repo":"apache/druid","slug":"fixedbucketshistogrambufferaggregator-does-not-sup-8620c3","errorCode":null,"errorMessage":"FixedBucketsHistogramBufferAggregator does not support getLong()","messagePattern":"FixedBucketsHistogramBufferAggregator does not support getLong\\(\\)","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/FixedBucketsHistogramBufferAggregator.java","lineNumber":78,"sourceCode":"    innerAggregator.aggregate(buf, position, val);\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(\"FixedBucketsHistogramBufferAggregator does not support getFloat()\");\n  }\n\n  @Override\n  public long getLong(ByteBuffer buf, int position)\n  {\n    throw new UnsupportedOperationException(\"FixedBucketsHistogramBufferAggregator does not support getLong()\");\n  }\n\n  @Override\n  public double getDouble(ByteBuffer buf, int position)\n  {\n    throw new UnsupportedOperationException(\"FixedBucketsHistogramBufferAggregator 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);","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/FixedBucketsHistogramBufferAggregator.java#L60-L96","documentation":"FixedBucketsHistogramBufferAggregator.getLong() unconditionally throws UnsupportedOperationException. A fixed-buckets histogram cannot be represented as a long, so any request to read the aggregation buffer as a long is invalid; the library fails fast rather than returning a meaningless value.","triggerScenarios":"A query execution path or custom aggregation framework invokes getLong() on the buffer for a fixedBucketsHistogram metric, e.g. a long-typed expectation from the column signature or a numeric post-aggregator applied directly to the histogram metric.","commonSituations":"Pointing a LongSumPostAggregator or SQL BIGINT-typed projection at a fixedBucketsHistogram column; framework code assuming all aggregators produce numeric buffers.","solutions":["Access the histogram via histogram-specific post-aggregators (quantile, min, max, sum) instead of raw long reads.","Ensure the query's output type for this metric is the complex/finalized histogram type, not LONG.","Refactor downstream code to consume FixedBucketsHistogram objects or their serialized base64 form."],"exampleFix":"// before\nLong v = agg.getLong(buf, pos);\n// after: apply a scalar-extracting post-aggregator first\n// {\"type\": \"max\", \"fieldName\": \"myHist\"}","handlingStrategy":"type-guard","validationCode":"if (aggregator instanceof FixedBucketsHistogramBufferAggregator) {\n  throw new IllegalStateException(\"Use histogram post-aggregators, not long reads\");\n}","typeGuard":"boolean supportsLong(BufferAggregator a) {\n  return !(a instanceof FixedBucketsHistogramBufferAggregator);\n}","tryCatchPattern":"try {\n  value = aggregator.getLong(buf, position);\n} catch (UnsupportedOperationException e) {\n  Object v = aggregator.get(buf, position);\n}","preventionTips":["Avoid projecting fixedBucketsHistogram metrics as BIGINT/LONG in SQL or native queries.","Use histogram post-aggregators (min, max, quantile, sum) to obtain numeric values.","Check the aggregator's comparator/type before numeric buffer access."],"tags":["druid","histogram","unsupported-operation"],"backgroundTag":"method-not-implemented","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}