apache/beam · error · java.lang.UnsupportedOperationException
The measure function is not recognized
Error message
The measure function is not recognized: ${funcName} What it means
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.
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
Example fix
// before MEASURES FINAL(COUNT(*)) AS cnt // after MEASURES COUNT(*) AS cnt -- or another function supported by the switch in BeamMatchRel
Defensive patterns
Strategy: validation
Validate before calling
// Allow-list measure functions before submitting MATCH_RECOGNIZE
Set<String> supported = Set.of("FIRST", "LAST", "RUNNING", "FINAL", "COUNT", "SUM", "AVG", "MAX", "MIN");
for (String fn : extractMeasureFunctions(measuresClause)) {
if (!supported.contains(fn.toUpperCase())) throw new IllegalArgumentException("Unsupported measure: " + fn);
} Try / catch
try {
result = sqlEnv.sqlQuery(matchRecognizeQuery).evaluate();
} catch (UnsupportedOperationException e) {
if (e.getMessage().startsWith("The measure function is not recognized")) {
// rewrite the MEASURES clause or compute it downstream
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
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
- CEP operation is not recognized
- Attempting to create database
- Attempting to 'USE CATALOG
- Cannot get column index from
- Cannot get limit count from RelNode tree with root
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/8b06f37e8e8de7c8.
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:347
break;
case LAST:
CEPFieldRef colLastField = (CEPFieldRef) call.getOperands().get(0);
CEPLiteral colLastIndex = (CEPLiteral) call.getOperands().get(1);
Row rowLastToProc =
patternRows.get(
patternRows.size() - 1 - colLastIndex.getDecimal().intValue());
if (newFieldBuilder == null) {
newFieldBuilder =
newRowBuilder.withFieldValue(
outName, rowLastToProc.getValue(colLastField.getIndex()));
} else {
newFieldBuilder =
newFieldBuilder.withFieldValue(
outName, rowLastToProc.getValue(colLastField.getIndex()));
}
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());
}
}View on GitHub (pinned to 12126d8942)