morrySnow opened a new pull request, #67892:
URL: https://github.com/apache/doris/pull/67892

   ## Problem
   
   Arithmetic simplification could change query results by moving factors 
across a nested division denominator. In particular, zero and nullable inputs 
could produce a non-NULL value after rewriting.
   
   ## Root cause
   
   The multiply/divide flattening traversal propagated the outer denominator 
polarity into the denominator subtree. It then inverted or moved the subtree 
multiplication and division operands into the enclosing expression, even though 
a denominator is an evaluation boundary.
   
   ## Reproduction
   
   1 / (1 / number) was rewritten to number * 1. For number = 0, the original 
expression evaluates to NULL while the rewritten expression evaluates to 0. The 
same unsafe flattening affected shapes such as x / (y / z) and x / (y * z).
   
   ## Fix
   
   Keep every complete subtree reached in denominator position as an atomic 
operand during multiply/divide flattening. The normal recursive rewrite still 
simplifies within that subtree, but no factor can be inverted or moved across 
its enclosing division boundary. Add focused unit coverage for integer, 
nullable, double, decimal, and zero cases, plus end-to-end plan and result 
checks.
   
   ## Tests
   
   - ./run-fe-ut.sh --run 
org.apache.doris.nereids.rules.expression.SimplifyArithmeticRuleTest
   - DISABLE_BUILD_UI=ON ./build.sh --fe
   - ./run-regression-test.sh --conf /tmp/env2-range-regression-conf.groovy 
--run -f 
regression-test/suites/nereids_rules_p0/expression/simplify_arithmetic/test_simplify_arithmetic.groovy
 -forceGenOut
   - ./run-regression-test.sh --conf /tmp/env2-range-regression-conf.groovy 
--run -f 
regression-test/suites/nereids_rules_p0/expression/simplify_arithmetic/test_simplify_arithmetic.groovy


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