{"record":{"id":"fb5771eab8b0e2ba","repo":"apache/skywalking","slug":"unsupported-compare-operation","errorCode":null,"errorMessage":"Unsupported compare operation: {}","messagePattern":"Unsupported compare operation: (.+?)","errorType":"exception","errorClass":"IllegalExpressionException","httpStatus":null,"severity":"error","filePath":"oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/CompareOp.java","lineNumber":32,"sourceCode":" * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\npackage org.apache.skywalking.mqe.rt.operation;\n\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 CompareOp {\n    public static ExpressionResult doCompareOP(ExpressionResult left,\n                                              ExpressionResult right,\n                                              int opType) throws IllegalExpressionException {\n        try {\n            return LROp.doLROp(left, right, opType, CompareOp::scalarCompareOp);\n        } catch (IllegalExpressionException e) {\n            throw new IllegalExpressionException(\"Unsupported compare operation: \" + e.getMessage());\n        }\n    }\n\n    private static int scalarCompareOp(double leftValue, double rightValue, int opType) {\n        int comparedResult = 0;\n        switch (opType) {\n            case MQEParser.DEQ:\n                comparedResult = boolToInt(leftValue == rightValue);\n                break;\n            case MQEParser.NEQ:\n                comparedResult = boolToInt(leftValue != rightValue);\n                break;\n            case MQEParser.GT:\n                comparedResult = boolToInt(leftValue > rightValue);\n                break;\n            case MQEParser.LT:\n                comparedResult = boolToInt(leftValue < rightValue);\n                break;","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/apache/skywalking/blob/102af09b4a56064e22050dded10e2c52e490d040/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/CompareOp.java#L14-L50","documentation":"IllegalExpressionException from CompareOp.doCompareOP wrapping the cause of a failed LROp.doLROp for comparison operators (==, !=, >, >=, <, <=). Message is 'Unsupported compare operation: <cause>' — normally the cause is LROp's 'Unsupported operation.' because the left/right ExpressionResultTypes have no defined pairing for comparison.","triggerScenarios":"Comparing result shapes LROp cannot pair: e.g. SORTED_LIST vs SORTED_LIST ('topn(a,10) > topn(b,10)'), RECORD_LIST vs a series, or labeled-vs-unlabeled series combos outside the supported branches (single-with-single, many-with-one, one-with-many, series-with-series).","commonSituations":"Dashboard expressions comparing two TopN lists; comparing a log/trace record list against a metric; comparing labeled and unlabeled metrics directly.","solutions":["Unwrap the cause; if it is 'Unsupported operation.', fix the operand shapes","Reduce list results to series or single values first: aggregate_labels(...) or apply the comparison before topn(...)","Ensure both operands are plain time-series (or one side a scalar literal) before comparing","Consult the MQE result-type matrix for allowed operand pairs per operator"],"exampleFix":"# before\ntopn(service_resp_time.sum(dt5m), 10, DES) > 100\n# after\ntopn((service_resp_time.sum(dt5m) > 100).sum(...), 10, DES)  # compare on the series, then topn","handlingStrategy":"type-guard","validationCode":"boolean comparablePair(ExpressionResultType l, ExpressionResultType r) {\n    return (l == SINGLE_VALUE && r == SINGLE_VALUE)\n        || ((l == TIME_SERIES_VALUES || l == SORTED_LIST || l == RECORD_LIST) && r == SINGLE_VALUE)\n        || (l == SINGLE_VALUE && (r == TIME_SERIES_VALUES || r == SORTED_LIST || r == RECORD_LIST))\n        || (l == TIME_SERIES_VALUES && r == TIME_SERIES_VALUES);\n}","typeGuard":"boolean isCompareSafe(org.apache.skywalking.oap.server.core.query.mqe.ExpressionResult r) {\n    ExpressionResultType t = r.getType();\n    return t == ExpressionResultType.SINGLE_VALUE || t == ExpressionResultType.TIME_SERIES_VALUES;\n}","tryCatchPattern":"catch (IllegalExpressionException e) { /* unwrap cause ('Unsupported operation.') and reshape operands to series×series or series×scalar */ }","preventionTips":["Compare series with series or scalars, never TopN list with list","Do comparisons before topn()/sort() in the expression","Keep boolean leaves explicit with 0/1 semantics"],"tags":["mqe","compare","type-mismatch","query","unsupported-operation"],"backgroundTag":null,"analyzedSha":"102af09b4a56064e22050dded10e2c52e490d040","analyzedAt":"2026-08-14T10:47:52.647Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}