apache/druid · error · java.lang.UnsupportedOperationException

StringFirstAggregator does not support getDouble()

Error message

StringFirstAggregator does not support getDouble()

What it means

StringLastBufferAggregator's getDouble(ByteBuffer,int) throws UnsupportedOperationException because a last-string aggregator has no double representation. The message mentions StringFirstAggregator because the first/last packages share message strings.

Source

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

    return StringFirstLastUtils.readPair(buf, position);
  }

  @Override
  public float getFloat(ByteBuffer buf, int position)
  {
    throw new UnsupportedOperationException("StringFirstAggregator does not support getFloat()");
  }

  @Override
  public long getLong(ByteBuffer buf, int position)
  {
    throw new UnsupportedOperationException("StringFirstAggregator does not support getLong()");
  }

  @Override
  public double getDouble(ByteBuffer buf, int position)
  {
    throw new UnsupportedOperationException("StringFirstAggregator does not support getDouble()");
  }

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

  @Override
  public void inspectRuntimeShape(RuntimeShapeInspector inspector)
  {
    inspector.visit("timeSelector", timeSelector);
    inspector.visit("valueSelector", valueSelector);
  }
}

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Use get(ByteBuffer,int) to read the string value
  2. Switch the metric to doubleLast/double aggregator if a double is required
  3. Dispatch on the factory's type name before calling numeric accessors

Example fix

// before
double d = bufAgg.getDouble(buf, position); // throws
// after
Object v = bufAgg.get(buf, position); // string
double d2 = v == null ? 0.0 : Double.parseDouble((String) v); // only if conversion intended
Defensive patterns

Strategy: type-guard

Validate before calling

if ("double".equals(factory.getTypeName())) { d = bufAgg.getDouble(buf, pos); }

Type guard

static boolean hasDoubleAccessor(AggregatorFactory f) { return f.getTypeName().equals("double"); }

Try / catch

try { d = bufAgg.getDouble(buf, pos); } catch (UnsupportedOperationException e) { d = Double.NaN; }

Prevention

When it happens

Trigger: Calling getDouble(buf, position) on a StringLastBufferAggregator when result code assumes all metrics are doubles.

Common situations: Custom group-by/topn result formatting that casts everything to double; plugin code migrated from numeric aggregators to string aggregators without updating accessors.

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/94309db0a414f483. Report an issue: GitHub.