public ScalarOperator rewrite(ScalarOperator root, List<ScalarOperatorRewriteRule> ruleList) {
        ScalarOperator result = root;

        context.reset();
        int changeNums;
        do {
            changeNums = context.changeNum();
            for (ScalarOperatorRewriteRule rule : ruleList) {
                result = rewriteByRule(result, rule);
            }

            if (changeNums > Config.max_planner_scalar_rewrite_num) {
                throw new StarRocksPlannerException("Planner rewrite scalar operator over limit",
                        ErrorType.INTERNAL_ERROR);
            }
        } while (changeNums != context.changeNum());

        return result;
    }
@Test
    public void testNormalizePredicate() {
        // b > a => a < b
        {
            BinaryPredicateOperator op = new BinaryPredicateOperator(BinaryType.GT,
                    new ColumnRefOperator(0, Type.VARCHAR, "b", true),
                    new ColumnRefOperator(1, Type.BIGINT, "a", true)
            );

            ScalarOperatorRewriter operatorRewriter = new ScalarOperatorRewriter();
            ScalarOperator result = operatorRewriter.rewrite(op, Lists.newArrayList(new MvNormalizePredicateRule()));

            Assert.assertEquals("1: a < 0: b", result.toString());
        }

        // b:101 > b:2 => b:2 < b:101
        {
            BinaryPredicateOperator op = new BinaryPredicateOperator(BinaryType.GT,
                    new ColumnRefOperator(101, Type.VARCHAR, "b", true),
                    new ColumnRefOperator(2, Type.BIGINT, "b", true)
            );

            ScalarOperatorRewriter operatorRewriter = new ScalarOperatorRewriter();
            ScalarOperator result = operatorRewriter.rewrite(op, Lists.newArrayList(new MvNormalizePredicateRule()));

            Assert.assertEquals("2: b < 101: b", result.toString());
        }
    }