apache/beam · error · UnsupportedOperationException
[ ] is not supported in SUM0
Error message
[%s] is not supported in SUM0
What it means
createSum0 builds the SUM0 aggregation (SUM where the sum of all-null input is 0 instead of NULL). It supports the same numeric types as SUM — INTEGER-family (FloatSum0/IntSum0), DOUBLE (DoubleSum0), DECIMAL (BigDecimalSum0) — and throws UnsupportedOperationException for any other field type.
Solutions
- Ensure the aggregated column's schema type is INTEGER, INT64, DOUBLE, or DECIMAL before the aggregation is planned.
- Cast the column to a supported numeric type in the SQL query.
- Implement a custom zero-returning CombineFn (mirroring DoubleSum0: extractOutput returns 0 when accumulator empty) for the needed type.
Example fix
// before CombineFn fn = BeamBuiltinAggregations.createSum0(Schema.FieldType.BOOLEAN); // throws // after CombineFn fn = BeamBuiltinAggregations.createSum0(Schema.FieldType.INT64);
Defensive patterns
Strategy: validation
Validate before calling
java.util.Set<Schema.TypeName> ok =
java.util.Set.of(Schema.TypeName.INTEGER, Schema.TypeName.INT64, Schema.TypeName.DOUBLE, Schema.TypeName.DECIMAL);
if (!ok.contains(fieldType.getTypeName())) {
throw new IllegalArgumentException("SUM0 unsupported for " + fieldType);
} Type guard
boolean sum0Supported(Schema.FieldType t) {
switch (t.getTypeName()) {
case INTEGER: case INT64: case DOUBLE: case DECIMAL: return true;
default: return false;
}
} Try / catch
try {
CombineFn fn = BeamBuiltinAggregations.createSum0(fieldType);
} catch (UnsupportedOperationException e) {
// substitute a custom zero-defaulting combiner
} Prevention
- Ensure SUM0-planned columns resolve to INTEGER/INT64/DOUBLE/DECIMAL.
- When constructing aggregates programmatically, validate Schema.FieldType before calling the factory.
- Track Beam SQL optimizer rewrites (SUM->SUM0) in query plans when debugging.
When it happens
Trigger: Calling BeamBuiltinAggregations.createSum0(fieldType) with a TypeName outside the supported numeric set (e.g. STRING, BOOLEAN, TIMESTAMP) — reached when Beam SQL plans a SUM0 aggregate (emitted for COUNT-style or null-safe SUM rewrites) over an unsupported column type.
Common situations: Optimizer rewriting SUM into SUM0 internally over a column type that was not validated; users constructing aggregation pipelines programmatically with the wrong Schema.FieldType.
Related errors
- [ ] is not supported in AVG
- [ ] is not supported in MAX
- [ ] is not supported in MIN
- [ ] is not supported in SUM
- [ ] is not supported in BIT_AND
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/54e0874b85759995.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/transform/BeamBuiltinAggregations.java:204
*/
static CombineFn createSum0(Schema.FieldType fieldType) {
switch (fieldType.getTypeName()) {
case INT32:
return new IntegerSum0();
case INT16:
return new ShortSum0();
case BYTE:
return new ByteSum0();
case INT64:
return new LongSum0();
case FLOAT:
return new FloatSum0();
case DOUBLE:
return new DoubleSum0();
case DECIMAL:
return new BigDecimalSum0();
default:
throw new UnsupportedOperationException(
String.format("[%s] is not supported in SUM0", fieldType));
}
}
/** {@link CombineFn} for AVG. */
static CombineFn createAvg(Schema.FieldType fieldType) {
switch (fieldType.getTypeName()) {
case INT32:
return new IntegerAvg();
case INT16:
return new ShortAvg();
case BYTE:
return new ByteAvg();
case INT64:
return new LongAvg();
case FLOAT:
return new FloatAvg();
case DOUBLE:View on GitHub (pinned to 12126d8942)