apache/druid · error · UnsupportedOperationException

StringAnyBufferAggregator does not support getFloat()

Error message

StringAnyBufferAggregator does not support getFloat()

What it means

StringAnyBufferAggregator aggregates string values, so its buffer only holds the resulting string; numeric accessors are meaningless and unsupported. Calling getFloat() throws UnsupportedOperationException by design.

Solutions

  1. Do not call getFloat() on a string any-aggregator; read the result as an Object/String via get()
  2. If a numeric result is needed, use a numeric aggregator (e.g. doubleSum/longSum) instead of 'any'
  3. Cast/parse the aggregated string downstream in a post-aggregator if numeric semantics are required

Example fix

// before
float v = bufferAggregator.getFloat(buf, position);
// after
Object v = bufferAggregator.get(buf, position); // string result
Defensive patterns

Strategy: type-guard

Validate before calling

if (aggFactory instanceof StringAnyAggregatorFactory) { /* handle as string, never call getFloat */ }

Type guard

if (!(factory instanceof StringAnyAggregatorFactory)) {
    float v = bufferAggregator.getFloat(buf, position);
} else {
    Object v = bufferAggregator.get(buf, position);
}

Try / catch

try {
    v = bufferAggregator.getFloat(buf, position);
} catch (UnsupportedOperationException e) {
    v = Float.NaN; // or fall back to string get()
}

Prevention

When it happens

Trigger: A query/aggregation pipeline calls bufferAggregator.getFloat(buf, position) on a StringAnyAggregatorFactory-created aggregator, i.e. the aggregation's output type was resolved as FLOAT instead of STRING.

Common situations: Querying an 'any' aggregator column expecting a numeric result; misconfigured post-aggregator or result-row numeric extraction on a string-typed aggregation.

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/963e0ef1157fcd06. Report an issue: GitHub.

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/query/aggregation/any/StringAnyBufferAggregator.java:109

  @Override
  public Object get(ByteBuffer buf, int position)
  {
    ByteBuffer copyBuffer = buf.duplicate();
    copyBuffer.position(position);
    int stringSizeBytes = copyBuffer.getInt();
    if (stringSizeBytes >= 0) {
      byte[] valueBytes = new byte[stringSizeBytes];
      copyBuffer.get(valueBytes, 0, stringSizeBytes);
      return StringUtils.fromUtf8(valueBytes);
    } else {
      return null;
    }
  }

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

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

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

  @Override
  public void close()
  {
    // no-op

View on GitHub (pinned to 9b90983fd2)