alamb opened a new issue #1160:
URL: https://github.com/apache/arrow-datafusion/issues/1160


   **Is your feature request related to a problem or challenge? Please describe 
what you are trying to do.**
   The constant folding and constant evaluation in 
https://github.com/apache/arrow-datafusion/blob/master/datafusion/src/optimizer/constant_folding.rs
 (and added to in https://github.com/apache/arrow-datafusion/pull/1153) can not 
fold certain types of expressions where it takes
   
   For example there is an expression like this in 
https://github.com/apache/arrow-datafusion/pull/1153
   ```
   now() < cast(to_timestamp(...) as int) + 5000000000
   ```
   
   It is entirely evaluateable at query time, however, as formulated in #1153 
it will not be folded  because it requires the constant evaluator to run after 
the simplifier (because the simplifier can fill in now()` and then the 
evaluator will fill in the rest). 
   
   However, there are other types of exprs such as `(true or false) != col` 
which need to have the constant evaluator run before the simplifier to be fully 
simplified.
   
   It is a more general problem where running either the `Simplifier` or 
`ConstEvaluator` could allow a second pass of the other to proceed
   
   **Describe the solution you'd like**
   In general this is typically handled with some sort of 'fixed point' 
algorithm where there is a loop that runs the two passes until the Expr is not 
changed. It may also be possible to combine the Simplifier pass with the 
constant rewriter. 
   
   
   **Describe alternatives you've considered**
   I think there are two possible approaches I can think if:
   1.  applying constant eval / simplifier in a loop until no changes are 
detected
   2. Combining the `ConstantEval` and `Simplify` steps into a single pass 
   
   **Additional context**
    https://github.com/apache/arrow-datafusion/pull/1153


-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to