{"record":{"id":"3ed8360744965225","repo":"apache/beam","slug":"the-comparator-is-not-supported-comparator","errorCode":null,"errorMessage":"the comparator is not supported: ${comparator}","messagePattern":"the comparator is not supported: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/nfa/NFA.java","lineNumber":498,"sourceCode":"      }\n      if (rightSideValue == null) {\n        return true;\n      }\n      switch (comparator) {\n        case EQUALS:\n          return leftSideValue.compareTo(rightSideValue) == 0;\n        case NOT_EQUALS:\n          return leftSideValue.compareTo(rightSideValue) != 0;\n        case GREATER_THAN:\n          return leftSideValue.compareTo(rightSideValue) > 0;\n        case GREATER_THAN_OR_EQUAL:\n          return leftSideValue.compareTo(rightSideValue) >= 0;\n        case LESS_THAN:\n          return leftSideValue.compareTo(rightSideValue) < 0;\n        case LESS_THAN_OR_EQUAL:\n          return leftSideValue.compareTo(rightSideValue) <= 0;\n        default:\n          throw new IllegalStateException(\n              \"the comparator is not supported: \" + comparator.toString());\n      }\n    }\n\n    // evaluates the condition value (left) given an input event\n    private CEPLiteral evalLeftSideCondition(CEPOperation inputOperation, Event inputEvent) {\n      if (inputOperation instanceof CEPLiteral) {\n        return (CEPLiteral) inputOperation;\n      } else if (inputOperation.getClass() == CEPFieldRef.class) {\n        return inputEvent.toCEPLiteral((CEPFieldRef) inputOperation);\n      } else if (inputOperation.getClass() == CEPCall.class) {\n        CEPCall call = (CEPCall) inputOperation;\n        CEPOperator operator = call.getOperator();\n        List<CEPOperation> operands = call.getOperands();\n        switch (operator.getCepKind()) {\n          case LAST:\n            return last(\n                operands.get(0), evalLeftSideCondition(operands.get(1), inputEvent), inputEvent);","sourceCodeStart":480,"sourceCodeEnd":516,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/nfa/NFA.java#L480-L516","documentation":"NFA.evalCondition compares left and right CEPLiteral values using the SQL comparator from the RexCall. The switch handles EQUAL, NOT_EQUAL, GREATER_THAN, GREATER_THAN_OR_EQUAL, LESS_THAN, LESS_THAN_OR_EQUAL; any other SqlOperator reaches default and throws IllegalStateException.","triggerScenarios":"A DEFINE condition whose comparison operator is not one of the six standard SQL comparison operators — e.g. IS DISTINCT FROM, IS NULL, LIKE, IN, or a custom operator reaching the comparator switch.","commonSituations":"Using IS NULL / LIKE / IN predicates inside MATCH_RECOGNIZE DEFINE clauses; Calcite rewriting comparisons into operator kinds the NFA does not enumerate.","solutions":["Rewrite the condition using only =, <>, <, <=, >, >= comparisons between field expressions and literals.","Replace IS NULL with explicit handling, e.g. compare after coalescing, or filter nulls before MATCH_RECOGNIZE.","Replace LIKE/IN with equality ranges or pre-computed boolean fields upstream.","Extend the switch in NFA.evalCondition to map the missing SqlOperator."],"exampleFix":"// before\nDEFINE A AS A.status LIKE 'ERR%'\n// after (upstream)\n.apply(MapElements.into(strings).via(...status...)) // then DEFINE A AS A.isError = TRUE","handlingStrategy":"validation","validationCode":"// Allow-list comparison operators in DEFINE conditions\nSet<SqlOperator> allowed = Set.of(EQUAL, NOT_EQUALS, LESS_THAN, LESS_THAN_OR_EQUAL, GREATER_THAN, GREATER_THAN_OR_EQUAL);\nif (!allowed.contains(op)) throw new IllegalArgumentException(\"Unsupported comparator in DEFINE: \" + op);","typeGuard":"boolean isSimpleComparison(SqlOperator op) { return op instanceof SqlBinaryOperator && COMPARISON_OPS.contains(op.getName().toUpperCase()); }","tryCatchPattern":"try { return nfa.proceed(...); } catch (IllegalStateException e) { throw new QueryValidationException(\"Unsupported comparator in DEFINE clause\", e); }","preventionTips":["Use only =, <>, <, <=, >, >= in DEFINE conditions.","Handle NULL via upstream filtering or COALESCE into a sentinel value.","Translate LIKE/IN needs into boolean fields computed before matching."],"tags":["java","nfa","cep","comparator","sql"],"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-14T16:17:12.679Z"}