{"record":{"id":"0c91df00e3cac79b","repo":"apache/druid","slug":"not-implemented-0c91df","errorCode":null,"errorMessage":"Not implemented","messagePattern":"Not implemented","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":500,"severity":"error","filePath":"extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchBuildAggregator.java","lineNumber":61,"sourceCode":"  @Override\n  public synchronized void aggregate()\n  {\n    if (valueSelector.isNull()) {\n      return;\n    }\n    sketch.update(valueSelector.getDouble());\n  }\n\n  @Override\n  public synchronized Object get()\n  {\n    return sketch;\n  }\n\n  @Override\n  public float getFloat()\n  {\n    throw new UnsupportedOperationException(\"Not implemented\");\n  }\n\n  @Override\n  public long getLong()\n  {\n    throw new UnsupportedOperationException(\"Not implemented\");\n  }\n\n  @Override\n  public synchronized void close()\n  {\n    sketch = null;\n  }\n}\n","sourceCodeStart":43,"sourceCodeEnd":76,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/DoublesSketchBuildAggregator.java#L43-L76","documentation":"DoublesSketchBuildAggregator accumulates a quantiles DoublesSketch, which is only meaningful as a sketch object. Druid's Aggregator interface requires getFloat()/getLong() implementations, but a sketch cannot be losslessly represented as a float, so the implementation deliberately throws UnsupportedOperationException to surface misuse rather than return a silently wrong number.","triggerScenarios":"Calling getFloat() on a build-phase quantilesDoublesSketch aggregator, e.g. configuring post-aggregators or column types that expect a primitive float result from an unfinalized sketch build.","commonSituations":"Selecting a sketch aggregator column with a numeric column type; custom code that reads aggregator results generically via getFloat; misconfigured post-aggregator arithmetic on a raw sketch column.","solutions":["Use get() instead, which returns the finalized value when shouldFinalize is true, or the sketch object otherwise","Apply a quantilesDoublesSketchToQuantile / -ToHistogram / -ToRank post-aggregator to extract numeric values from the sketch","Set shouldFinalize=true if a numeric result is what the query needs"],"exampleFix":"// before\nfloat v = aggregator.getFloat();\n// after\nObject v = aggregator.get();\ndouble d = ((Number) v).doubleValue(); // when shouldFinalize=true","handlingStrategy":"type-guard","validationCode":"Object result = aggregator.get();\nif (!(result instanceof Number) && !(result instanceof DoublesSketch)) {\n  throw new IllegalStateException(\"Unexpected sketch aggregator result type: \" + result.getClass());\n}","typeGuard":"boolean isFinalizedNumeric(Aggregator agg) {\n  return agg.get() instanceof Number; // true only when shouldFinalize=true\n}","tryCatchPattern":"try {\n  return aggregator.getFloat();\n} catch (UnsupportedOperationException e) {\n  Object v = aggregator.get();\n  return v instanceof Number ? ((Number) v).floatValue() : Float.NaN;\n}","preventionTips":["Never call getFloat/getLong on sketch aggregators; always use get()","Set shouldFinalize=true when a numeric result is desired","Use sketch post-aggregators for quantiles/histograms/ranks"],"tags":["java","druid","sketch","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-14T05:17:10.506Z"}