vikrantmehta123 opened a new pull request, #26995: URL: https://github.com/apache/datafusion/pull/26995
## Which issue does this PR close? - Closes #26910. ## Rationale for this change This fixes a bug, where SimplifyExpression optimization's preimage rewrite was incorrectly evaluating volatile arguments twice. This gave incorrect query result. For example, an Expr like `floor(random() * 10) = 3` was being transformed into `random() * 10 >= 3 AND random() * 10 < 4`, which yielded incorrect results as `random()` is volatile and is being evaluated twice. ## What changes are included in this PR? In this change, we stop the simplification, if any of the argument is Volatile. ## What is the testing strategy for this PR? There are two new `sqllogictests` added in `floor_preimage.slt`. These cover two codepaths from which this issue could have been reached: 1. IN predicates 2. Equality predicates These check whether the optimizer correctly disallows the queries with volatile arguments. Please suggest if there are more. ## Are there any user-facing changes? No, I think. But the user is expected to see correct query results for volatile args after this fix. --- **Disclaimer:** I have used previously raised draft [PR](https://github.com/apache/datafusion/pull/25458) as reference and have taken help from an LLM to understand the issue and arrive at a solution and tests that looked reasonable to me. -- 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]
