You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/07/20 07:31:59 UTC

[GitHub] [doris] adonis0147 commented on a diff in pull request #10667: [Enhancement](Nereids) add some expr rewrite rule and plan rewrite rule of rewrite its expression

adonis0147 commented on code in PR #10667:
URL: https://github.com/apache/doris/pull/10667#discussion_r925269681


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/util/ExpressionUtils.java:
##########
@@ -102,8 +104,13 @@ public static Expression combine(ExpressionType op, List<Expression> expressions
             }
         }
 
-        Optional<Expression> result =
-                distinctExpressions.stream().reduce((left, right) -> new CompoundPredicate(op, left, right));
+        Optional<Expression> result = distinctExpressions.stream().reduce((left, right) -> {
+            if (op == ExpressionType.AND) {
+                return new And(left, right);
+            } else {
+                return new Or(left, right);
+            }
+        });

Review Comment:
   Due to the previous check `Preconditions.checkArgument(op == ExpressionType.AND || op == ExpressionType.OR)`, here we can safely use `new CompoundPredicate(op, left, right))` to simplify the code.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org