apache/beam · error · UnsupportedOperationException
[ ] is not supported in MAX
Error message
[%s] is not supported in MAX
What it means
Beam SQL's createMax builds a CombineFn for the MAX aggregation but only supports INTEGER (Max.ofIntegers), INT64 (Max.ofLongs), and DOUBLE (Max.ofDoubles) field types. Any other Schema.FieldType reaching the default branch throws UnsupportedOperationException with the field type in the message. This is a compile-time-unsupported-type guard: the aggregation was planned with a type MAX cannot combine natively.
Solutions
- Change the query to apply MAX only to integer or double columns; cast the column first, e.g. SELECT MAX(CAST(col AS DOUBLE)) FROM ...
- If MAX over DECIMAL is needed, implement a custom CombineFn (e.g. extend Combine.BinaryCombineFn<BigDecimal> with compareTo) and register it instead of relying on the builtin MAX.
- Check the inferred schema type of the source (PCollection schema or table provider) and adjust it so the column maps to INTEGER/INT64/DOUBLE.
Example fix
// before
Schema.FieldType t = Schema.FieldType.DECIMAL; // MAX over DECIMAL unsupported
CombineFn fn = BeamBuiltinAggregations.createMax(t); // throws
// after
// Query side: SELECT MAX(CAST(amount AS DOUBLE)) ...
// or custom combiner:
CombineFn<BigDecimal, ?, BigDecimal> fn =
Combine.BinaryCombineFn<BigDecimal>::apply == null ? null
: new CustMax<>(BigDecimal.class); // CustMax<T extends Comparable<T>> exists in this class Defensive patterns
Strategy: validation
Validate before calling
// before planning MAX
java.util.Set<Schema.TypeName> ok =
java.util.Set.of(Schema.TypeName.INTEGER, Schema.TypeName.INT64, Schema.TypeName.DOUBLE);
if (!ok.contains(fieldType.getTypeName())) {
throw new IllegalArgumentException("MAX unsupported for " + fieldType);
} Type guard
boolean maxSupported(Schema.FieldType t) {
return t.getTypeName() == Schema.TypeName.INTEGER
|| t.getTypeName() == Schema.TypeName.INT64
|| t.getTypeName() == Schema.TypeName.DOUBLE;
} Try / catch
try {
CombineFn fn = BeamBuiltinAggregations.createMax(fieldType);
} catch (UnsupportedOperationException e) {
// fall back to cast-to-double pipeline or custom combiner
} Prevention
- Apply MAX/MIN/SUM/AVG only to INT32/INT64/DOUBLE/DECIMAL columns in Beam SQL.
- Cast non-conforming columns (CAST(... AS DOUBLE/BIGINT)) at query time.
- Verify inferred schema types of your source before writing aggregations.
When it happens
Trigger: Calling BeamBuiltinAggregations.createMax(fieldType) with a fieldType whose TypeName is not INTEGER, INT64, or DOUBLE (e.g. DECIMAL, FLOAT, STRING, DATE) — typically via a SQL query like SELECT MAX(varchar_col) or MAX(decimal_col) through zetasql/calcite translation.
Common situations: Writing Beam SQL queries where MAX is applied to a DECIMAL/NUMERIC column, a string column, or a timestamp column whose inferred schema type is not one of the three supported TypeNames; also occurs after schema evolution changes a column type away from INT32/INT64/DOUBLE.
Related errors
- [ ] is not supported in AVG
- [ ] is not supported in MIN
- [ ] is not supported in SUM
- [ ] is not supported in SUM0
- [ ] is not supported in BIT_AND
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/05f8ed39cbbf6e96.
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:129
return new CustMax<>();
}
switch (fieldType.getTypeName()) {
case BOOLEAN:
case INT16:
case BYTE:
case FLOAT:
case DATETIME:
case DECIMAL:
case STRING:
return new CustMax<>();
case INT32:
return Max.ofIntegers();
case INT64:
return Max.ofLongs();
case DOUBLE:
return Max.ofDoubles();
default:
throw new UnsupportedOperationException(
String.format("[%s] is not supported in MAX", fieldType));
}
}
/** {@link CombineFn} for MIN based on {@link Min} and {@link Combine.BinaryCombineFn}. */
static CombineFn createMin(Schema.FieldType fieldType) {
if (CalciteUtils.isDateTimeType(fieldType)) {
return new CustMin();
}
switch (fieldType.getTypeName()) {
case BOOLEAN:
case BYTE:
case INT16:
case FLOAT:
case DATETIME:
case DECIMAL:
case STRING:
return new CustMin();View on GitHub (pinned to 12126d8942)