apache/beam · error · UnsupportedOperationException

[ ] is not supported in MIN

Error message

[%s] is not supported in MIN

What it means

createMin builds the CombineFn for the SQL MIN aggregation and, like createMax, only supports INTEGER (Min.ofIntegers), INT64 (Min.ofLongs), and DOUBLE (Min.ofDoubles). Any other Schema.FieldType falls into the default branch and throws UnsupportedOperationException naming the unsupported field type.

Solutions

  1. Cast the column to a supported type in SQL, e.g. SELECT MIN(CAST(col AS DOUBLE)) ...
  2. Write a custom Combine.BinaryCombineFn (e.g. using CustMax-style comparison, or Min.of with a comparator) for the orderable type you need and use it instead of the builtin.
  3. Fix the schema/type mapping so the column is inferred as INT32/INT64/DOUBLE.

Example fix

// before (unsupported)
CombineFn fn = BeamBuiltinAggregations.createMin(Schema.FieldType.STRING);

// after: SQL-side cast
// SELECT MIN(CAST(score AS DOUBLE)) FROM t
// or custom:
Combine.BinaryCombineFn<String> fn = (a, b) -> a.compareTo(b) <= 0 ? a : b;
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);
if (!ok.contains(fieldType.getTypeName())) {
  throw new IllegalArgumentException("MIN unsupported for " + fieldType);
}

Type guard

boolean minSupported(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.createMin(fieldType);
} catch (UnsupportedOperationException e) {
  fn = new CustMax<>(Comparable.class); // or a custom min combiner for the type
}

Prevention

When it happens

Trigger: Calling BeamBuiltinAggregations.createMin(fieldType) with a TypeName other than INTEGER, INT64, or DOUBLE — e.g. a SQL query SELECT MIN(name) over a STRING column or MIN(decimal_col) over DECIMAL.

Common situations: MIN/MAX applied to string, decimal, boolean, or date columns in Beam SQL; schema inference mapping a numeric column to DECIMAL instead of DOUBLE; users porting queries from other SQL engines that allow MIN on any orderable type.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/71f1dd6ac3f786ca. 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:155

      return new CustMin();
    }
    switch (fieldType.getTypeName()) {
      case BOOLEAN:
      case BYTE:
      case INT16:
      case FLOAT:
      case DATETIME:
      case DECIMAL:
      case STRING:
        return new CustMin();
      case INT32:
        return Min.ofIntegers();
      case INT64:
        return Min.ofLongs();
      case DOUBLE:
        return Min.ofDoubles();
      default:
        throw new UnsupportedOperationException(
            String.format("[%s] is not supported in MIN", fieldType));
    }
  }

  /** {@link CombineFn} for Sum based on {@link Sum} and {@link Combine.BinaryCombineFn}. */
  static CombineFn createSum(Schema.FieldType fieldType) {
    switch (fieldType.getTypeName()) {
      case INT32:
        return Sum.ofIntegers();
      case INT16:
        return new ShortSum();
      case BYTE:
        return new ByteSum();
      case INT64:
        return new LongSum();
      case FLOAT:
        return new FloatSum();
      case DOUBLE:

View on GitHub (pinned to 12126d8942)