apache/beam · error · IllegalStateException
the right side CEP operation is not legal: ${class}
Error message
the right side CEP operation is not legal: ${class} What it means
Beam SQL's CEP (complex event processing) NFA engine evaluates the right-side operand of a MATCH_RECOGNIZE pattern's quantifier/condition. evalRightSideCondition only understands CEPOperation node types it knows (e.g. CEPLiteral, CEPFieldRef with specific operators); anything else means the parsed pattern produced an operand shape the NFA cannot interpret. The library throws IllegalStateException because this reflects an unhandled AST node class, not a user-data problem.
Source
Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/nfa/NFA.java:551
if (inputOperation instanceof CEPLiteral) {
return (CEPLiteral) inputOperation;
} else if (inputOperation.getClass() == CEPCall.class) {
CEPCall call = (CEPCall) inputOperation;
CEPOperator operator = call.getOperator();
List<CEPOperation> operands = call.getOperands();
switch (operator.getCepKind()) {
case PLUS:
return plus(
evalRightSideCondition(operands.get(0), inputEvent),
evalRightSideCondition(operands.get(1), inputEvent));
case PREV:
return prev(operands.get(0), (CEPLiteral) operands.get(1), ptr, curEvent, inputEvent);
default:
throw new UnsupportedOperationException(
"the function is not supported for now: " + operator.getCepKind().toString());
}
} else {
throw new IllegalStateException(
"the right side CEP operation is not legal: " + inputOperation.getClass().toString());
}
}
/* below are function implementations */
// represents the PREV operation
private CEPLiteral prev(
CEPOperation opr1,
CEPLiteral opr2,
EventPointer curPointer,
Event curEvent,
Event inputEvent) {
if (opr1.getClass() != CEPFieldRef.class) {
throw new IllegalStateException(
"the first argument of the PREV operation should be a field reference. Provided: "
+ opr1.getClass().toString());
}View on GitHub (pinned to 12126d8942)
Solutions
- Inspect the PATTERN clause and simplify it to supported constructs (literals, field refs, supported quantifier operators)
- Print the class named in the message and compare against the switch in NFA.evalRightSideCondition to see which case is missing
- Check the Beam version's CEP documentation for supported operators and upgrade to a release that adds the operator you need
- If the operator should be supported, file/patch an issue adding a case in NFA.java's evalRightSideCondition
Example fix
// before PATTERN (e1 e2 e3+) -- uses an operator the NFA does not implement on the right side // after PATTERN (e1 e2 e3) -- restrict to supported operators/operands
Defensive patterns
Strategy: validation
Validate before calling
// before running the CEP query, check pattern operands
for (CEPOperation op : operands) {
if (!(op instanceof CEPLiteral || op instanceof CEPFieldRef)) {
throw new IllegalArgumentException("Unsupported CEP operand: " + op.getClass());
}
} Type guard
boolean isSupportedOperand(CEPOperation op) {
return op instanceof CEPLiteral || op instanceof CEPFieldRef;
} Try / catch
try {
runCepQuery(pattern);
} catch (IllegalStateException e) {
if (e.getMessage().contains("right side CEP operation is not legal")) {
// fall back to a simplified pattern or surface a clear query-authoring error
} else throw e;
} Prevention
- Restrict MATCH_RECOGNIZE patterns to documented operators and operand shapes
- Keep CEP patterns simple; test each DEFINE expression on a bounded sample first
- Pin a Beam version with known CEP support and review its limitations before authoring patterns
When it happens
Trigger: A MATCH_RECOGNIZE PATTERN clause contains a right-side operand whose CEPOperation subclass is not one of the types handled by the switch in evalRightSideCondition (e.g. an unsupported operator kind or nested operation), or a CEP operator kind hits the preceding UnsupportedOperationException default.
Common situations: Writing an exotic or newly added CEP pattern syntax that the parser accepts but the NFA evaluator has not implemented; using a Beam version where the CEP feature is still experimental and only a subset of operators is supported.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- RexNode not supported: ${className}
- the function in Measures is not recognized.
- The other object should be an instance of CEPLiteral
- The other CEPLiteral should have type , given:
- the comparator is not supported: ${comparator}
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/9b421bc0c9e6f263.
Report an issue: GitHub.