Is your feature request related to a problem or challenge?
When simplifying expressions in general, care must be taken with nulls. For example it seems like this expression can be simplified to false:
however, if A is null then the expression actually evaluates to null and not false
The existing simplification code handles these cases by checking is_nullable:
https://github.com/apache/arrow-datafusion/blob/71efcf5ee8900a1efe12fb812e210e6941060733/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs#L575-L582
However, if we are using A AND !A as a filter, we can actually simplify the whole thing to false because for filtering:
true --> row is kept
false --> row is not kept
null --> row is not kept (same as false)
Describe the solution you'd like
I would like someone to figure out how to take advantage of the above observation to apply more simplification rules when simplifying predicates
Describe alternatives you've considered
No response
Additional context
No response
Is your feature request related to a problem or challenge?
When simplifying expressions in general, care must be taken with nulls. For example it seems like this expression can be simplified to
false:A AND !Ahowever, if
Aisnullthen the expression actually evaluates tonulland notfalseThe existing simplification code handles these cases by checking
is_nullable:https://github.com/apache/arrow-datafusion/blob/71efcf5ee8900a1efe12fb812e210e6941060733/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs#L575-L582
However, if we are using
A AND !Aas a filter, we can actually simplify the whole thing tofalsebecause for filtering:true--> row is keptfalse--> row is not keptnull--> row is not kept (same as false)Describe the solution you'd like
I would like someone to figure out how to take advantage of the above observation to apply more simplification rules when simplifying predicates
Describe alternatives you've considered
No response
Additional context
No response