{"record":{"id":"71f1dd6ac3f786ca","repo":"apache/beam","slug":"s-is-not-supported-in-min","errorCode":null,"errorMessage":"[%s] is not supported in MIN","messagePattern":"\\[(.+?)\\] is not supported in MIN","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/transform/BeamBuiltinAggregations.java","lineNumber":155,"sourceCode":"      return new CustMin();\n    }\n    switch (fieldType.getTypeName()) {\n      case BOOLEAN:\n      case BYTE:\n      case INT16:\n      case FLOAT:\n      case DATETIME:\n      case DECIMAL:\n      case STRING:\n        return new CustMin();\n      case INT32:\n        return Min.ofIntegers();\n      case INT64:\n        return Min.ofLongs();\n      case DOUBLE:\n        return Min.ofDoubles();\n      default:\n        throw new UnsupportedOperationException(\n            String.format(\"[%s] is not supported in MIN\", fieldType));\n    }\n  }\n\n  /** {@link CombineFn} for Sum based on {@link Sum} and {@link Combine.BinaryCombineFn}. */\n  static CombineFn createSum(Schema.FieldType fieldType) {\n    switch (fieldType.getTypeName()) {\n      case INT32:\n        return Sum.ofIntegers();\n      case INT16:\n        return new ShortSum();\n      case BYTE:\n        return new ByteSum();\n      case INT64:\n        return new LongSum();\n      case FLOAT:\n        return new FloatSum();\n      case DOUBLE:","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/transform/BeamBuiltinAggregations.java#L137-L173","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Cast the column to a supported type in SQL, e.g. SELECT MIN(CAST(col AS DOUBLE)) ...","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.","Fix the schema/type mapping so the column is inferred as INT32/INT64/DOUBLE."],"exampleFix":"// before (unsupported)\nCombineFn fn = BeamBuiltinAggregations.createMin(Schema.FieldType.STRING);\n\n// after: SQL-side cast\n// SELECT MIN(CAST(score AS DOUBLE)) FROM t\n// or custom:\nCombine.BinaryCombineFn<String> fn = (a, b) -> a.compareTo(b) <= 0 ? a : b;","handlingStrategy":"validation","validationCode":"java.util.Set<Schema.TypeName> ok =\n    java.util.Set.of(Schema.TypeName.INTEGER, Schema.TypeName.INT64, Schema.TypeName.DOUBLE);\nif (!ok.contains(fieldType.getTypeName())) {\n  throw new IllegalArgumentException(\"MIN unsupported for \" + fieldType);\n}","typeGuard":"boolean minSupported(Schema.FieldType t) {\n  return t.getTypeName() == Schema.TypeName.INTEGER\n      || t.getTypeName() == Schema.TypeName.INT64\n      || t.getTypeName() == Schema.TypeName.DOUBLE;\n}","tryCatchPattern":"try {\n  CombineFn fn = BeamBuiltinAggregations.createMin(fieldType);\n} catch (UnsupportedOperationException e) {\n  fn = new CustMax<>(Comparable.class); // or a custom min combiner for the type\n}","preventionTips":["Never MIN/MAX string or decimal columns in Beam SQL without casting.","Keep column schema types aligned with the aggregation's supported set.","Add a unit test per aggregation + type combination in your pipeline."],"tags":["beam-sql","unsupported-type","aggregation","java"],"backgroundTag":"unsupported-enum-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}