apache/druid · error · java.lang.UnsupportedOperationException
StringFirstAggregator does not support getDouble()
Error message
StringFirstAggregator does not support getDouble()
What it means
StringFirstBufferAggregator stores a serialized string pair per group, so getDouble(ByteBuffer,int) is unsupported and always throws UnsupportedOperationException. Reading the buffer cell as a double is invalid by design.
Source
Thrown at processing/src/main/java/org/apache/druid/query/aggregation/firstlast/first/StringFirstBufferAggregator.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
- Read the cell via get(buf, position) instead of getDouble.
- Remove DOUBLE outputType or arithmetic post-aggregations on stringFirst.
- Use doubleFirst aggregation for numeric earliest values.
- Check the aggregator's type before invoking numeric getters.
Example fix
// before double v = bufAggregator.getDouble(buf, pos); // after Object v = bufAggregator.get(buf, pos); // SerializablePairLongString
Defensive patterns
Strategy: type-guard
Validate before calling
if (bufAggregator instanceof StringFirstBufferAggregator) {
Object v = bufAggregator.get(buf, position);
} else {
double v = bufAggregator.getDouble(buf, position);
} Type guard
boolean supportsDouble(BufferAggregator a) {
return !(a instanceof StringFirstBufferAggregator);
} Try / catch
try {
return agg.getDouble(buf, pos);
} catch (UnsupportedOperationException e) {
Object pair = agg.get(buf, pos);
return pair == null ? 0d : Double.parseDouble(String.valueOf(((SerializablePairLongString) pair).rhs));
} Prevention
- Do not declare DOUBLE outputType for stringFirst.
- Use doubleFirst for double results.
- Extract buffered string cells with get(buf, position).
When it happens
Trigger: Calling getDouble(buf, position) on a StringFirstBufferAggregator — usually a uniform numeric read path or DOUBLE outputType applied to stringFirst in a buffer-aggregated query.
Common situations: Group-by v2 with numeric outputType over stringFirst; shared result-extraction code calling getDouble on every aggregator cell.
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
- StringFirstAggregator does not support getFloat()
- StringFirstAggregator does not support getLong()
- HistogramBufferAggregator does not support getFloat()
- HistogramBufferAggregator does not support getLong()
- HistogramBufferAggregator does not support getDouble
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/39df7bf597f81569.
Report an issue: GitHub.