{"record":{"id":"811ae599352337a1","repo":"apache/druid","slug":"not-implemented-811ae5","errorCode":null,"errorMessage":"not implemented","messagePattern":"not implemented","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"warning","filePath":"extensions-contrib/momentsketch/src/main/java/org/apache/druid/query/aggregation/momentsketch/aggregator/MomentSketchBuildAggregator.java","lineNumber":65,"sourceCode":"  @Override\n  public void aggregate()\n  {\n    if (valueSelector.isNull()) {\n      return;\n    }\n    momentsSketch.add(valueSelector.getDouble());\n  }\n\n  @Override\n  public Object get()\n  {\n    return momentsSketch;\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 Aggregator clone()\n  {\n    return new MomentSketchBuildAggregator(valueSelector, k, compress);\n  }\n\n  @Override\n  public void close()\n  {\n    momentsSketch = null;","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-contrib/momentsketch/src/main/java/org/apache/druid/query/aggregation/momentsketch/aggregator/MomentSketchBuildAggregator.java#L47-L83","documentation":"MomentSketchBuildAggregator.getFloat unconditionally throws UnsupportedOperationException because a Moments Sketch is a composite object, not a scalar, so it cannot be converted to a float. This surfaces when a query or post-aggregator requests the sketch aggregation as a FLOAT value instead of reading it via getObject/getComplex.","triggerScenarios":"A Druid native query or SQL query selects the momentsketch aggregator with an outputType of FLOAT, or a post-aggregator/expression reads getFloat() on a build aggregator for the sketch metric.","commonSituations":"Copying a query template that used float aggregations and just swapping in the momentsketch aggregator; SQL planner coercing the column to FLOAT; tooling that introspects all aggregators generically assuming numeric output.","solutions":["Request the sketch as its complex/sketch output type (e.g. no type coercion; use getObject / the sketch post-aggregators) rather than FLOAT.","Remove any post-aggregators or expressions that treat the sketch column as a numeric float.","If a numeric summary is needed, add a dedicated sketch post-aggregator (e.g. quantile/mean) that computes a float from the sketch.","If the sketch is only an intermediate, mark the metric as a COMPLEX aggregator input and aggregate via the factory's merge path."],"exampleFix":"// before\nAggregatorFactory agg = new MomentSketchAggregatorFactory(\"sketch\", \"value\", 50, true);\nquery.outputType.put(\"sketch\", ValueType.FLOAT); // throws\n// after\nquery.outputType.put(\"sketch\", ValueType.COMPLEX);\nPostAggregator mean = new MomentSketchMeanPostAggregator(\"mean\", \"sketch\");","handlingStrategy":"type-guard","validationCode":"// ensure query never requests FLOAT output for sketch aggregators\nif (query.getOutputType(\"sketch\") == ValueType.FLOAT) {\n  throw new IllegalArgumentException(\"momentsketch must use COMPLEX output, not FLOAT\");\n}","typeGuard":"if (agg instanceof MomentSketchAggregatorFactory) {\n  // read via getObject / complex accessor, never getFloat()\n}","tryCatchPattern":"try {\n  return aggregator.getFloat();\n} catch (UnsupportedOperationException e) {\n  throw new IllegalStateException(\"Use COMPLEX output / sketch post-aggregators for momentsketch\", e);\n}","preventionTips":["Never configure FLOAT/LONG output types for momentsketch aggregations.","Extract scalars only via sketch post-aggregators (quantile, mean).","When writing generic aggregator tooling, branch on aggregator type before calling getFloat/getLong.","Read sketch values via getObject()."],"tags":["unsupported-operation","aggregation","sketch","druid"],"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"}