jayzhan211 commented on PR #25476:
URL: https://github.com/apache/datafusion/pull/25476#issuecomment-6496900283

   @adriangb I checked both. Postgres has the same behavior as DataFusion 
today: it expands `BETWEEN` in the parser and evaluates the value twice (35953 
of 100000 rows for your query on 14.17). The source has known about it for 
years, with an "XXX this is really wrong since it results in multiple runtime 
evaluations of what may be volatile expressions" comment in 
`transformAExprBetween` that is still on master. DuckDB evaluates it once 
(19938), but that comes from its general `BETWEEN` node for any value that 
isn't a plain column, not from a volatile special case.
   
   Since Postgres has accepted this for many years and the case is rare, I 
think it's fine to leave it as it is. Anyone who needs one evaluation can use a 
subquery, e.g. `SELECT ... FROM (SELECT random() AS r ...) WHERE r BETWEEN 0.4 
AND 0.6`, which already evaluates `random()` once. Would you be okay closing 
this PR and the issue?
   


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