ninglinLiu opened a new pull request, #26918:
URL: https://github.com/apache/datafusion/pull/26918

   ## Which issue does this PR close?
   
   Closes #26910.
   
   ## Rationale for this change
   
   The preimage rewrite turns `floor(x) = 3` into `x >= 3 AND x < 4`. When `x` 
is volatile (e.g. `random() * 10`), each copy draws a new value, so 
`floor(random() * 10) = 3` returns ~28% of rows instead of ~10%.
   
   `get_preimage` already requires an immutable UDF; this also skips the 
rewrite when any argument expression is volatile.
   
   ## What changes are included in this PR?
   
   - Guard in `get_preimage` with `args.iter().any(Expr::is_volatile)`
   - sqllogictest EXPLAIN cases in `floor_preimage.slt` showing the rewrite is 
skipped for `floor(random() * 10)`
   
   ## Are these changes tested?
   
   Yes — new sqllogictest cases in `floor_preimage.slt`.
   
   ## Are there any user-facing changes?
   
   No (correctness fix for an optimizer rewrite).
   
   ## AI assistance
   
   AI-assisted (Cursor). I verified the volatile-argument path in 
`get_preimage`, confirmed the EXPLAIN plans, and wrote the commit message.


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