apache/beam · error · UnsupportedOperationException

the function in Measures is not recognized.

Error message

the function in Measures is not recognized.

What it means

CEPUtils.getFieldType() resolves the SQL type of a MEASURES expression by locating a field reference (RexPatternFieldRef) among a RexCall's operands. If the call's operands contain no recognizable field ref, it throws UnsupportedOperationException, meaning the MEASURES function's output type cannot be inferred.

Solutions

  1. Reference at least one pattern variable field in each MEASURES expression (e.g. A.price instead of a constant).
  2. Cast or wrap the constant so it is tied to a field, or compute it outside MATCH_RECOGNIZE.
  3. If legitimate, extend CEPUtils.getFieldType() to fall back to the RexCall's own inferred type via the type factory.
  4. Catch UnsupportedOperationException at query-translation time and report the unsupported MEASURES expression to the user.

Example fix

// before
MEASURES 1 + 1 AS two
// after
MEASURES A.quantity + 1 AS qtyPlusOne
Defensive patterns

Strategy: validation

Validate before calling

// Ensure each MEASURES expr references at least one pattern field
if (!referencesPatternField(measuresRexNode)) {
  throw new IllegalArgumentException("MEASURES expression must reference a pattern field");
}

Type guard

boolean referencesPatternField(RexNode n) { return getFieldRef(n) != null; } // reuse CEPUtils.getFieldRef

Try / catch

try { return CEPUtils.getFieldType(call, schema); } catch (UnsupportedOperationException e) { throw new QueryValidationException("Unresolvable MEASURES expression", e); }

Prevention

When it happens

Trigger: A MEASURES clause expression (RexCall) whose operands include no RexPatternFieldRef reachable via getFieldRef() — e.g. constant-only expressions or functions over literals.

Common situations: MEASURES with expressions like 1+1, constant aggregates, or functions applied only to literals in a MATCH_RECOGNIZE query; Calcite rewrites stripping field refs.

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


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/5877096f188c58da. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/cep/CEPUtils.java:210

      return streamSchema.getField(field.getIndex()).getType();
    } else if (measureOperation.getClass() == CEPCall.class) {

      CEPCall call = (CEPCall) measureOperation;
      CEPKind oprKind = call.getOperator().getCepKind();

      if (oprKind == CEPKind.SUM || oprKind == CEPKind.COUNT) {
        return Schema.FieldType.INT32;
      } else if (oprKind == CEPKind.AVG) {
        return Schema.FieldType.DOUBLE;
      }
      CEPFieldRef refOpt;
      for (CEPOperation i : call.getOperands()) {
        refOpt = getFieldRef(i);
        if (refOpt != null) {
          return streamSchema.getField(refOpt.getIndex()).getType();
        }
      }
      throw new UnsupportedOperationException("the function in Measures is not recognized.");
    } else {
      throw new UnsupportedOperationException("the function in Measures is not recognized.");
    }
  }
}

View on GitHub (pinned to 12126d8942)