{"record":{"id":"31c509a76e6a326a","repo":"apache/druid","slug":"stringanybufferaggregator-does-not-support-getdoub","errorCode":null,"errorMessage":"StringAnyBufferAggregator does not support getDouble()","messagePattern":"StringAnyBufferAggregator does not support getDouble\\(\\)","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/query/aggregation/any/StringAnyBufferAggregator.java","lineNumber":121,"sourceCode":"    }\n  }\n\n  @Override\n  public float getFloat(ByteBuffer buf, int position)\n  {\n    throw new UnsupportedOperationException(\"StringAnyBufferAggregator does not support getFloat()\");\n  }\n\n  @Override\n  public long getLong(ByteBuffer buf, int position)\n  {\n    throw new UnsupportedOperationException(\"StringAnyBufferAggregator does not support getLong()\");\n  }\n\n  @Override\n  public double getDouble(ByteBuffer buf, int position)\n  {\n    throw new UnsupportedOperationException(\"StringAnyBufferAggregator does not support getDouble()\");\n  }\n\n  @Override\n  public void close()\n  {\n    // no-op\n  }\n}\n","sourceCodeStart":103,"sourceCodeEnd":130,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/query/aggregation/any/StringAnyBufferAggregator.java#L103-L130","documentation":"Same unsupported-accessor guard as getLong: StringAnyBufferAggregator.getDouble() always throws UnsupportedOperationException because the aggregate value is a UTF-8 string that cannot be read as a double from the buffer. Fires when the query asks for double-typed access on a string ANY aggregate.","triggerScenarios":"Calling bufferAggregator.getDouble(buf, position) on a StringAnyAggregatorFactory-created aggregator when numeric output is assumed.","commonSituations":"Treating a string any-aggregation as numeric in query post-processing; swapping an aggregator type without updating numeric accessors in custom code.","solutions":["Cast/parse the resulting string explicitly after aggregation instead of using getDouble().","Aggregate a numeric column directly if a double result is required.","Verify the output type in the query plan matches VARCHAR for the ANY aggregator."],"exampleFix":"// before\ndouble v = bufferAggregator.getDouble(buf, position);\n// after\nObject v = bufferAggregator.get(buf, position); // string result","handlingStrategy":"validation","validationCode":"if (aggFactory instanceof StringAnyAggregatorFactory) { /* read via get(), not getDouble */ }","typeGuard":"if (factory instanceof StringAnyAggregatorFactory) {\n    Object v = bufferAggregator.get(buf, position);\n} else {\n    double v = bufferAggregator.getDouble(buf, position);\n}","tryCatchPattern":"try {\n    v = bufferAggregator.getDouble(buf, position);\n} catch (UnsupportedOperationException e) {\n    v = Double.NaN; // or fall back to string get()\n}","preventionTips":["Use a double aggregator when double output is needed","Branch on factory type before numeric access","Parse string results explicitly when numeric values are required"],"tags":["java","druid","aggregation","unsupported"],"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"}