apache/skywalking · error · IllegalExpressionException

Unsupported compare operation: {}

Error message

Unsupported compare operation: {}

What it means

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.

Source

Thrown at oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/CompareOp.java:32

 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package org.apache.skywalking.mqe.rt.operation;

import org.apache.skywalking.mqe.rt.exception.IllegalExpressionException;
import org.apache.skywalking.mqe.rt.grammar.MQEParser;
import org.apache.skywalking.oap.server.core.query.mqe.ExpressionResult;

public class CompareOp {
    public static ExpressionResult doCompareOP(ExpressionResult left,
                                              ExpressionResult right,
                                              int opType) throws IllegalExpressionException {
        try {
            return LROp.doLROp(left, right, opType, CompareOp::scalarCompareOp);
        } catch (IllegalExpressionException e) {
            throw new IllegalExpressionException("Unsupported compare operation: " + e.getMessage());
        }
    }

    private static int scalarCompareOp(double leftValue, double rightValue, int opType) {
        int comparedResult = 0;
        switch (opType) {
            case MQEParser.DEQ:
                comparedResult = boolToInt(leftValue == rightValue);
                break;
            case MQEParser.NEQ:
                comparedResult = boolToInt(leftValue != rightValue);
                break;
            case MQEParser.GT:
                comparedResult = boolToInt(leftValue > rightValue);
                break;
            case MQEParser.LT:
                comparedResult = boolToInt(leftValue < rightValue);
                break;

View on GitHub (pinned to 102af09b4a)

Solutions

  1. Unwrap the cause; if it is 'Unsupported operation.', fix the operand shapes
  2. Reduce list results to series or single values first: aggregate_labels(...) or apply the comparison before topn(...)
  3. Ensure both operands are plain time-series (or one side a scalar literal) before comparing
  4. Consult the MQE result-type matrix for allowed operand pairs per operator

Example fix

# before
topn(service_resp_time.sum(dt5m), 10, DES) > 100
# after
topn((service_resp_time.sum(dt5m) > 100).sum(...), 10, DES)  # compare on the series, then topn
Defensive patterns

Strategy: type-guard

Validate before calling

boolean comparablePair(ExpressionResultType l, ExpressionResultType r) {
    return (l == SINGLE_VALUE && r == SINGLE_VALUE)
        || ((l == TIME_SERIES_VALUES || l == SORTED_LIST || l == RECORD_LIST) && r == SINGLE_VALUE)
        || (l == SINGLE_VALUE && (r == TIME_SERIES_VALUES || r == SORTED_LIST || r == RECORD_LIST))
        || (l == TIME_SERIES_VALUES && r == TIME_SERIES_VALUES);
}

Type guard

boolean isCompareSafe(org.apache.skywalking.oap.server.core.query.mqe.ExpressionResult r) {
    ExpressionResultType t = r.getType();
    return t == ExpressionResultType.SINGLE_VALUE || t == ExpressionResultType.TIME_SERIES_VALUES;
}

Try / catch

catch (IllegalExpressionException e) { /* unwrap cause ('Unsupported operation.') and reshape operands to series×series or series×scalar */ }

Prevention

When it happens

Trigger: 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).

Common situations: Dashboard expressions comparing two TopN lists; comparing a log/trace record list against a metric; comparing labeled and unlabeled metrics directly.

Related errors


AI-assisted analysis of apache/skywalking@102af09b4a (2026-08-14). Data as JSON: /api/errors/fb5771eab8b0e2ba. Report an issue: GitHub.