apache/beam · error · java.lang.UnsupportedOperationException

CEP operation is not recognized

Error message

CEP operation is not recognized: ${className}

What it means

In BeamMatchRel's measure processing, each operand of the measure expression must be a recognized CEP operation class (e.g. CEPFieldRef, CEPOperation subclasses like function calls). If an operand's class is unknown, processElement throws UnsupportedOperationException with the class name.

Solutions

  1. Simplify the measure expression to plain field references and supported CEP functions (FIRST/LAST/etc.)
  2. Verify all operands are deserialized as CEPOperation subclasses (check for class-loading/serialization issues if CEPOperands come from a plan)
  3. Upgrade Beam/Calcite to a version where the operand class is handled

Example fix

// before
MEASURES SOME_UNSUPPORTED_FUNC(price) AS p
// after
MEASURES FIRST(price) AS p
Defensive patterns

Strategy: validation

Validate before calling

// Ensure all operands of measure expressions are simple field refs or supported CEP ops
boolean isSupportedCepOperand(Object opr) {
  return opr instanceof CEPFieldRef || SUPPORTED_CEP_OPERATION_CLASSES.stream().anyMatch(c -> c.isInstance(opr));
}

Try / catch

try {
  result = sqlEnv.sqlQuery(q).evaluate();
} catch (UnsupportedOperationException e) {
  if (e.getMessage().startsWith("CEP operation is not recognized")) {
    // simplify the measure expression to supported CEP operations
  } else throw e;
}

Prevention

When it happens

Trigger: A MATCH_RECOGNIZE MEASURES/PATTERN expression containing an operator or operand type that isn't a known CEPOperation subclass, so opr.getClass() matches no branch in the if/else chain.

Common situations: Exotic measure expressions mixing unsupported Calcite operators with CEP references; version drift between Calcite and Beam CEP classes; hand-built RelNodes with non-CEP operands.

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


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/de50a354e5aa1541. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamMatchRel.java:362

                  }
                  break;
                default:
                  throw new UnsupportedOperationException(
                      "The measure function is not recognized: " + funcName.name());
              }
            } else if (opr.getClass() == CEPFieldRef.class) {
              Row rowToProc = patternRows.get(0);
              CEPFieldRef fieldRef = (CEPFieldRef) opr;
              if (newFieldBuilder == null) {
                newFieldBuilder =
                    newRowBuilder.withFieldValue(outName, rowToProc.getValue(fieldRef.getIndex()));
              } else {
                newFieldBuilder =
                    newFieldBuilder.withFieldValue(
                        outName, rowToProc.getValue(fieldRef.getIndex()));
              }
            } else {
              throw new UnsupportedOperationException(
                  "CEP operation is not recognized: " + opr.getClass().getName());
            }
          }
          Row newRow;
          if (newFieldBuilder == null) {
            newRow = newRowBuilder.build();
          } else {
            newRow = newFieldBuilder.build();
          }
          out.output(newRow);
        }
      }
    }
  }

  private static class SortPerKey extends DoFn<KV<Row, Iterable<Row>>, KV<Row, Iterable<Row>>> {

    private final ArrayList<OrderKey> orderKeys;

View on GitHub (pinned to 12126d8942)