apache/beam · error · IllegalStateException
the left side CEP operation is not legal: ${class}
Error message
the left side CEP operation is not legal: ${class} What it means
In NFA.evalLeftSideCondition, the input CEPOperation must be a CEPOperator (RexCall-derived) to be reduced; if it is some other CEPOperation subclass (e.g. an unexpected literal or field-ref wrapper) the else branch throws IllegalStateException with the operation's class name.
Source
Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/nfa/NFA.java:526
return inputEvent.toCEPLiteral((CEPFieldRef) inputOperation);
} else if (inputOperation.getClass() == CEPCall.class) {
CEPCall call = (CEPCall) inputOperation;
CEPOperator operator = call.getOperator();
List<CEPOperation> operands = call.getOperands();
switch (operator.getCepKind()) {
case LAST:
return last(
operands.get(0), evalLeftSideCondition(operands.get(1), inputEvent), inputEvent);
case PLUS:
return plus(
evalLeftSideCondition(operands.get(0), inputEvent),
evalLeftSideCondition(operands.get(1), inputEvent));
default:
throw new UnsupportedOperationException(
"the function is not supported for now: " + operator.getCepKind().toString());
}
} else {
throw new IllegalStateException(
"the left side CEP operation is not legal: " + inputOperation.getClass().toString());
}
}
// evaluates the condition value (right) given an input event
private CEPLiteral evalRightSideCondition(CEPOperation inputOperation, Event inputEvent) {
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:View on GitHub (pinned to 12126d8942)
Solutions
- Inspect the named class in the message and simplify the DEFINE expression to standard field-vs-literal comparisons.
- Use only supported patterns: field refs, literals, and supported operators on each side of the comparison.
- File/patch an issue in CEPOperation.of() if a valid RexNode shape is being converted to the wrong CEPOperation type.
- Upgrade Beam — newer versions broaden CEP expression support.
Example fix
// before DEFINE A AS CASE WHEN A.x > 0 THEN 1 ELSE 0 END > 0 // after DEFINE A AS A.x > 0
Defensive patterns
Strategy: validation
Validate before calling
if (!(inputOperation instanceof CEPOperator || inputOperation instanceof CEPLiteral || inputOperation instanceof CEPFieldRef)) {
throw new IllegalArgumentException("Unexpected CEPOperation class: " + inputOperation.getClass());
} Type guard
boolean isKnownCepOperation(CEPOperation op) { return op instanceof CEPOperator || op instanceof CEPLiteral || op instanceof CEPFieldRef; } Try / catch
try { return evalLeftSideCondition(op, event); } catch (IllegalStateException e) { throw new QueryTranslationException("Malformed CEP operation in DEFINE", e); } Prevention
- Keep DEFINE expressions simple; avoid constructs that may convert to unexpected CEPOperation classes.
- Add a translation-time assert that converted operations are of known subclasses.
- Track Beam CEP improvements and upgrade when complex expressions become supported.
When it happens
Trigger: The left operand of a DEFINE comparison resolves to a CEPOperation that is neither CEPLiteral, CEPFieldRef, nor CEPOperator — typically an unexpected expression shape produced during translation of the MATCH_RECOGNIZE query.
Common situations: Complex/nested expressions in DEFINE that the CEPOperation converter mapped to an unexpected class; internal bugs or version mismatches between Calcite translation and the NFA evaluator.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- the comparator is not supported: ${comparator}
- The other object should be an instance of CEPLiteral
- The other CEPLiteral should have type , given:
- RexNode not supported: ${className}
- the function in Measures is not recognized.
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/eb50189f2eb392c4.
Report an issue: GitHub.