apache/druid · error · java.lang.UnsupportedOperationException
StringFirstAggregator does not support getLong()
Error message
StringFirstAggregator does not support getLong()
What it means
StringFirstBufferAggregator's per-group cell holds a serialized string pair, so getLong(ByteBuffer,int) is unsupported and always throws UnsupportedOperationException. Numeric long reads of string-first aggregates are invalid.
Source
Thrown at processing/src/main/java/org/apache/druid/query/aggregation/firstlast/first/StringFirstBufferAggregator.java:121
}
}
@Override
public Object get(ByteBuffer buf, int position)
{
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);View on GitHub (pinned to 9b90983fd2)
Solutions
- Use get(buf, position) to obtain the deserialized string pair.
- Correct the outputType or post-aggregator to expect a string.
- Switch to longFirst aggregation when a numeric earliest value is required.
- Branch on aggregator type before calling numeric getters.
Example fix
// before long v = bufAggregator.getLong(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 {
long v = bufAggregator.getLong(buf, position);
} Type guard
boolean supportsLong(BufferAggregator a) {
return !(a instanceof StringFirstBufferAggregator);
} Try / catch
try {
return agg.getLong(buf, pos);
} catch (UnsupportedOperationException e) {
Object pair = agg.get(buf, pos);
return pair == null ? 0L : Long.parseLong(String.valueOf(((SerializablePairLongString) pair).rhs));
} Prevention
- Do not declare LONG outputType for stringFirst in buffered queries.
- Use longFirst for long results.
- Branch on aggregator type in generic result readers.
When it happens
Trigger: Calling getLong(buf, position) on a StringFirstBufferAggregator — e.g. code path assuming long-typed aggregator output, or outputType LONG configured for stringFirst with buffer aggregation enabled.
Common situations: Vectorized/buffered group-by queries with a numeric outputType on stringFirst; generic result-reading utilities calling getLong for all aggregators.
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 getDouble()
- 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/c8ff23e753418c4c.
Report an issue: GitHub.