{"record":{"id":"8b06f37e8e8de7c8","repo":"apache/beam","slug":"the-measure-function-is-not-recognized-funcname","errorCode":null,"errorMessage":"The measure function is not recognized: ${funcName}","messagePattern":"The measure function is not recognized: (.+?)","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamMatchRel.java","lineNumber":347,"sourceCode":"                  break;\n                case LAST:\n                  CEPFieldRef colLastField = (CEPFieldRef) call.getOperands().get(0);\n                  CEPLiteral colLastIndex = (CEPLiteral) call.getOperands().get(1);\n                  Row rowLastToProc =\n                      patternRows.get(\n                          patternRows.size() - 1 - colLastIndex.getDecimal().intValue());\n                  if (newFieldBuilder == null) {\n                    newFieldBuilder =\n                        newRowBuilder.withFieldValue(\n                            outName, rowLastToProc.getValue(colLastField.getIndex()));\n                  } else {\n                    newFieldBuilder =\n                        newFieldBuilder.withFieldValue(\n                            outName, rowLastToProc.getValue(colLastField.getIndex()));\n                  }\n                  break;\n                default:\n                  throw new UnsupportedOperationException(\n                      \"The measure function is not recognized: \" + funcName.name());\n              }\n            } else if (opr.getClass() == CEPFieldRef.class) {\n              Row rowToProc = patternRows.get(0);\n              CEPFieldRef fieldRef = (CEPFieldRef) opr;\n              if (newFieldBuilder == null) {\n                newFieldBuilder =\n                    newRowBuilder.withFieldValue(outName, rowToProc.getValue(fieldRef.getIndex()));\n              } else {\n                newFieldBuilder =\n                    newFieldBuilder.withFieldValue(\n                        outName, rowToProc.getValue(fieldRef.getIndex()));\n              }\n            } else {\n              throw new UnsupportedOperationException(\n                  \"CEP operation is not recognized: \" + opr.getClass().getName());\n            }\n          }","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamMatchRel.java#L329-L365","documentation":"BeamMatchRel implements CEP MATCH_RECOGNIZE. When building measure output rows it maps each measure operation to a known function (e.g. FIRST, LAST, RUNNING/COUNT style enums). If the measure function enum value (funcName) has no switch branch, processElement throws UnsupportedOperationException naming the unrecognized function.","triggerScenarios":"A MATCH_RECOGNIZE query whose MEASURES clause uses a function that Beam's CEP implementation has no switch case for (an unsupported or newly added Calcite measure function).","commonSituations":"Using measure functions like FINAL/LAST variants, CLASSIFIER, or MATCH_NUMBER that aren't implemented in the Beam version in use; upgrading Calcite so new enum values appear.","solutions":["Rewrite the MEASURES clause to use only supported measure functions (e.g. FIRST, LAST with supported forms)","Check the Beam version's BeamMatchRel source for supported funcName values and upgrade if support was added later","Compute unsupported aggregates outside MATCH_RECOGNIZE in a downstream PTransform"],"exampleFix":"// before\nMEASURES FINAL(COUNT(*)) AS cnt\n// after\nMEASURES COUNT(*) AS cnt  -- or another function supported by the switch in BeamMatchRel","handlingStrategy":"validation","validationCode":"// Allow-list measure functions before submitting MATCH_RECOGNIZE\nSet<String> supported = Set.of(\"FIRST\", \"LAST\", \"RUNNING\", \"FINAL\", \"COUNT\", \"SUM\", \"AVG\", \"MAX\", \"MIN\");\nfor (String fn : extractMeasureFunctions(measuresClause)) {\n  if (!supported.contains(fn.toUpperCase())) throw new IllegalArgumentException(\"Unsupported measure: \" + fn);\n}","typeGuard":null,"tryCatchPattern":"try {\n  result = sqlEnv.sqlQuery(matchRecognizeQuery).evaluate();\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().startsWith(\"The measure function is not recognized\")) {\n    // rewrite the MEASURES clause or compute it downstream\n  } else throw e;\n}","preventionTips":["Check BeamMatchRel's switch cases for the exact supported funcName set per Beam version","Avoid newly added Calcite measure functions until implemented in Beam CEP","Add integration tests covering each measure function used"],"tags":["sql","cep","match-recognize","beam"],"backgroundTag":"unsupported-operation","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"}