apache/druid · error · java.lang.UnsupportedOperationException

StringLastAggregator does not support getDouble()

Error message

StringLastAggregator does not support getDouble()

What it means

StringLastAggregator stores the last observed string value (pair of timestamp + string) and cannot yield a double. getDouble() is required by the Aggregator interface but is intentionally unimplemented, throwing UnsupportedOperationException to surface type misuse early.

Solutions

  1. Read the string value via the aggregator's string/get() result path instead of getDouble()
  2. Switch to a numeric aggregator (doubleLast) when a double result is required
  3. Dispatch on AggregatorFactory.getTypeName() before calling numeric accessors
  4. CAST the string metric to DOUBLE in SQL if numeric conversion is intended

Example fix

// before
double d = agg.getDouble(); // throws
// after
if ("double".equals(factory.getTypeName())) {
  double d = agg.getDouble();
} else {
  Object s = agg.get();
}
Defensive patterns

Strategy: type-guard

Validate before calling

if ("string".equals(factory.getTypeName())) { /* read string value via agg.get() */ }

Type guard

static boolean isNumericAggregator(AggregatorFactory f) { return f.getTypeName().matches("long|float|double"); }

Try / catch

try { d = agg.getDouble(); } catch (UnsupportedOperationException e) { d = Double.NaN; }

Prevention

When it happens

Trigger: Calling getDouble() on a StringLastAggregator instance, e.g. when query result extraction assumes numeric metrics or when a vectorized/non-vectorized code path blindly calls getDouble for all metrics.

Common situations: Building custom Druid extensions or result formats that read all aggregators as doubles; misconfiguring a metric as string-last but consuming it as a numeric in a dashboard or post-aggregator.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/0f0d1be92c09649f. Report an issue: GitHub.

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/query/aggregation/firstlast/last/StringLastAggregator.java:107

    return new SerializablePairLongString(lastTime, StringUtils.chop(lastValue, maxStringBytes));
  }

  @Override
  public float getFloat()
  {
    throw new UnsupportedOperationException("StringLastAggregator does not support getFloat()");
  }

  @Override
  public long getLong()
  {
    throw new UnsupportedOperationException("StringLastAggregator does not support getLong()");
  }

  @Override
  public double getDouble()
  {
    throw new UnsupportedOperationException("StringLastAggregator does not support getDouble()");
  }

  @Override
  public void close()
  {
    // no resources to cleanup
  }
}

View on GitHub (pinned to 9b90983fd2)