{"record":{"id":"1197cb0b69241b2c","repo":"apache/skywalking","slug":"unsupported-function-1197cb","errorCode":null,"errorMessage":"Unsupported function.","messagePattern":"Unsupported function\\.","errorType":"exception","errorClass":"IllegalExpressionException","httpStatus":null,"severity":"error","filePath":"oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/MathematicalFunctionOp.java","lineNumber":40,"sourceCode":"import java.math.RoundingMode;\nimport java.util.function.Function;\nimport org.apache.skywalking.mqe.rt.exception.IllegalExpressionException;\nimport org.apache.skywalking.mqe.rt.grammar.MQEParser;\nimport org.apache.skywalking.oap.server.core.query.mqe.ExpressionResult;\n\npublic class MathematicalFunctionOp {\n    public static ExpressionResult doFunction0Op(ExpressionResult expResult,\n                                                 int opType) throws IllegalExpressionException {\n        switch (opType) {\n            case MQEParser.ABS:\n                return MathematicalFunctionOp.transResult(expResult, Math::abs);\n            case MQEParser.CEIL:\n                return MathematicalFunctionOp.transResult(expResult, Math::ceil);\n            case MQEParser.FLOOR:\n                return MathematicalFunctionOp.transResult(expResult, Math::floor);\n        }\n\n        throw new IllegalExpressionException(\"Unsupported function.\");\n    }\n\n    public static ExpressionResult doFunction1Op(ExpressionResult expResult,\n                                                 int opType,\n                                                 int scale) throws IllegalExpressionException {\n        switch (opType) {\n            case MQEParser.ROUND:\n                return MathematicalFunctionOp.transResult(expResult, aDouble -> {\n                    BigDecimal bd = BigDecimal.valueOf(aDouble);\n                    return bd.setScale(scale, RoundingMode.HALF_UP).doubleValue();\n                });\n        }\n\n        throw new IllegalExpressionException(\"Unsupported function.\");\n    }\n\n    private static ExpressionResult transResult(ExpressionResult expResult, Function<Double, Double> calculator) {\n        expResult.getResults().forEach(resultValues -> {","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/apache/skywalking/blob/102af09b4a56064e22050dded10e2c52e490d040/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/MathematicalFunctionOp.java#L22-L58","documentation":"MathematicalFunctionOp.doFunction0Op handles zero-argument scalar math functions over an ExpressionResult: only abs, ceil, and floor are implemented. Any other token type reaching the switch throws 'Unsupported function.'. Like error 93, the ANTLR grammar normally prevents other tokens from reaching here, so this is a defensive default guarding grammar/runtime version mismatch.","triggerScenarios":"An MQE expression invoking a function token that resolves to neither ABS, CEIL nor FLOOR in the doFunction0Op dispatch — e.g. a forked grammar token, or a mqe-rt jar older than the mqe-grammar jar that parsed the query.","commonSituations":"Custom OAP builds with new math functions added to the grammar but not the runtime; mixed-version jars after a partial upgrade; a hand-edited or generated visitor passing the wrong opType constant.","solutions":["Restrict queries to the supported set: abs(...), ceil(...), floor(...) (and round(...) with scale, handled by doFunction1Op)","If you added a grammar token, implement its case in doFunction0Op/doFunction1Op and rebuild","Verify mqe-grammar and mqe-rt jars in the deployment are the same version","Re-run the simplest failing expression to confirm which token is unsupported"],"exampleFix":"// before\nquery: sqrt(metric)   // not supported by this OAP\n// after\nquery: abs(metric)","handlingStrategy":"try-catch","validationCode":"Set<String> supportedFn0 = Set.of(\"abs\", \"ceil\", \"floor\");\nif (!supportedFn0.contains(fnName)) throw new IllegalArgumentException(\"unsupported: \" + fnName);","typeGuard":null,"tryCatchPattern":"catch (IllegalExpressionException e) { /* unsupported zero-arg math function — check function list for your OAP version */ }","preventionTips":["Restrict queries to abs/ceil/floor/round","Never mix parser and runtime jars from different OAP builds"],"tags":["mqe","query-engine","math-functions","unsupported-operation"],"backgroundTag":null,"analyzedSha":"102af09b4a56064e22050dded10e2c52e490d040","analyzedAt":"2026-08-14T10:47:52.647Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}