yujun777 commented on code in PR #45543: URL: https://github.com/apache/doris/pull/45543#discussion_r1895366470
########## 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: isAddOrSub is the input argument. it means only extract +- sub exprs, or only extract */ sub exprs. -- 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-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org