-
Couldn't load subscription status.
- Fork 1.7k
Description
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 constant_folding.rs(and added to in #1153) can not fold certain types of expressions where it takes
For example there is an expression like this in #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:
- applying constant eval / simplifier in a loop until no changes are detected
- Combining the
ConstantEvalandSimplifysteps into a single pass
Additional context
#1153