-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
Now that we have a nice ConstantPropagator and Simplifier framework, there are additional predicate rewrites we can do to improve query performance
Describe the solution you'd like
Implement additional algebraic simplification / rewrite rules to constant_folding.rs after #1153 has been merged
Types of standard rewrites I think it would be good to have:
true OR <expr> --> true
false OR <expr> --> expr
true AND <expr> --> <expr>
false AND <expr> --> false
There is also an interesting one in #1153 that would rotatate expr trees to isolate volatile functions:
(rand() + 1) + 2 --> rand() + (1 + 2)
The reason for doing that rewrite is that then the constant evaluator could convert to rand() + 3
Describe alternatives you've considered
There are various automated rewriting rules such as egg / tokomak (drafted in #1066 and #441 by @Dandandan and @pjmore ) which might be better / more powerful than implementing our own rules
Additional context
I am sure other query optimization systems have a good set of rewrite rules that we could investigate. I bet both postgres and spark have interesting optimizations to do.