github-actions[bot] commented on code in PR #67892:
URL: https://github.com/apache/doris/pull/67892#discussion_r4002069722


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/SimplifyArithmeticRule.java:
##########
@@ -143,6 +143,14 @@ private static List<Operand> flatten(Expression expr, 
boolean isAddOrSub) {
     // flag: true for '+' or '*', false for '-' or '/'
     // isAddOrSub: true for extract only "+" or "-" sub expressions, false for 
extract only "*" or "/" sub expressions
     private static void doFlatten(boolean flag, Expression expr, boolean 
isAddOrSub, List<Operand> result) {
+        if (!isAddOrSub && !flag) {
+            // A complete denominator is an evaluation boundary. Flattening 
its multiply/divide
+            // children into the enclosing expression can invert them or move 
them to the numerator,
+            // changing division-by-zero, null, overflow, and floating-point 
behavior. Keep the
+            // subtree atomic here; process() will still simplify it 
recursively within its boundary.

Review Comment:
   [P1] Preserve operand order around the atomic denominator
   
   This guard keeps the denominator's descendants together, but `process()` can 
still move a surrounding constant across the intact divisor. For the analyzed 
DOUBLE tree `(D / 2.0) / (B / C)`, `doFlatten` now yields `[+D, -2.0, -(B / 
C)]`; the variable/constant partition then rebuilds `(D / (B / C)) / 2.0` (the 
changed expectations at lines 104-109 encode the same relocation). With `D = 
Double.MAX_VALUE`, `B = 1.0`, and `C = 2.0`, the original returns 
`Double.MAX_VALUE`, while the rewritten tree overflows at `D / 0.5` and returns 
infinity. Please make an atomic negative operand an ordering barrier, or 
otherwise preserve factors on their original side, and cover this 
surrounding-factor case.



-- 
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