yujun777 commented on code in PR #45543:
URL: https://github.com/apache/doris/pull/45543#discussion_r1895396247


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/SimplifyArithmeticRule.java:
##########
@@ -129,43 +135,68 @@ private static Expression process(BinaryArithmetic 
arithmetic, boolean isAddOrSu
 
     private static List<Operand> flatten(Expression expr, boolean isAddOrSub) {
         List<Operand> result = Lists.newArrayList();
-        if (isAddOrSub) {
-            flattenAddSubtract(true, expr, result);
-        } else {
-            flattenMultiplyDivide(true, expr, result);
-        }
+        doFlatten(true, expr, isAddOrSub, result, Optional.empty());
         return result;
     }
 
-    private static void flattenAddSubtract(boolean flag, Expression expr, 
List<Operand> result) {
-        if (TypeUtils.isAddOrSubtract(expr)) {
-            BinaryArithmetic arithmetic = (BinaryArithmetic) expr;
-            flattenAddSubtract(flag, arithmetic.left(), result);
-            if (TypeUtils.isSubtract(expr) && !flag) {
-                flattenAddSubtract(true, arithmetic.right(), result);
-            } else if (TypeUtils.isAdd(expr) && !flag) {
-                flattenAddSubtract(false, arithmetic.right(), result);
+    private static void doFlatten(boolean flag, Expression expr, boolean 
isAddOrSub, List<Operand> result,

Review Comment:
   had add annotation



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to