{"record":{"id":"18aa29dc6519fdc9","repo":"apache/druid","slug":"stringanyaggregator-does-not-support-getdouble","errorCode":null,"errorMessage":"StringAnyAggregator does not support getDouble()","messagePattern":"StringAnyAggregator does not support getDouble\\(\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/query/aggregation/any/StringAnyAggregator.java","lineNumber":98,"sourceCode":"    return foundValue;\n  }\n\n  @Override\n  public float getFloat()\n  {\n    throw new UnsupportedOperationException(\"StringAnyAggregator does not support getFloat()\");\n  }\n\n  @Override\n  public long getLong()\n  {\n    throw new UnsupportedOperationException(\"StringAnyAggregator does not support getLong()\");\n  }\n\n  @Override\n  public double getDouble()\n  {\n    throw new UnsupportedOperationException(\"StringAnyAggregator does not support getDouble()\");\n  }\n\n  @Override\n  public void close()\n  {\n    // no-op\n  }\n}\n","sourceCodeStart":80,"sourceCodeEnd":107,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/query/aggregation/any/StringAnyAggregator.java#L80-L107","documentation":"StringAnyAggregator's getDouble() throws UnsupportedOperationException with this message; the aggregator holds a string value and refuses to present it as a double. Typed accessors on this class exist solely to fail fast on type misuse instead of producing misleading numeric results.","triggerScenarios":"Calling getDouble() on a stringAny aggregator's result — e.g. a doubleSum/arithmetic post-aggregator, an expression referencing the metric numerically, or generic result-row code that assumes double-typed metrics.","commonSituations":"Native queries with numeric post-aggregators bound to stringAny metrics; dashboards/tools that iterate aggregators and call getDouble() unconditionally; SQL plans where a VARCHAR any-aggregation is consumed by numeric functions.","solutions":["Use getString() and a CastPostAggregator to DOUBLE before any numeric post-aggregation","Aggregate the underlying numeric column with doubleAny or another numeric aggregator instead of the string column","Update result-consuming code to check the aggregator's type (string vs numeric) before choosing an accessor","Re-model the datasource so numeric data is stored with a numeric type"],"exampleFix":"// before\nrow.getDouble(\"stringAnyMetric\")\n// after\nString s = row.getString(\"stringAnyMetric\");\ndouble d = s == null ? Double.NaN : Double.parseDouble(s); // or CastPostAggregator to DOUBLE","handlingStrategy":"type-guard","validationCode":"if (aggregator instanceof StringAnyAggregator) {\n  throw new ISE(\"stringAny metric cannot be read as double\");\n}","typeGuard":"boolean supportsDouble(Aggregator a) { return !(a instanceof StringAnyAggregator); }","tryCatchPattern":"try {\n  double d = aggregator.getDouble();\n} catch (UnsupportedOperationException e) {\n  String s = aggregator.getString();\n  double d = s == null ? Double.NaN : Double.parseDouble(s);\n}","preventionTips":["Use getString() for stringAny results; reserve getDouble() for numeric aggregators","Add CastPostAggregator (to DOUBLE) between string metrics and numeric post-aggregators","Store numeric data with numeric column types to avoid string aggregation paths","Tools iterating all aggregators must check types before calling typed getters"],"tags":["aggregation","unsupported-operation","type-mismatch","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"}