Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve boolean simplifications for nullable fields #12769

Closed
eejbyfeldt opened this issue Oct 5, 2024 · 0 comments · Fixed by #12746
Closed

Improve boolean simplifications for nullable fields #12769

eejbyfeldt opened this issue Oct 5, 2024 · 0 comments · Fixed by #12746
Labels
enhancement New feature or request

Comments

@eejbyfeldt
Copy link
Contributor

Is your feature request related to a problem or challenge?

Datafusion currently knows hot to do the simplifications A OR (A AND B) -> A and A AND (B OR A) -> A but only does them when B is not nullable.

Describe the solution you'd like

We should perform the simplifications regardless of the nullabillity of B. Because the simplification still holds even if B is null see:

> CREATE TABLE t (v BOOLEAN) as values (true), (false), (NULL);
> select t.v, t2.v, t.v AND (t.v OR t2.v), t.v OR (t.v AND t2.v) from t cross join t as t2;
+-------+-------+---------------------+---------------------+
| v     | v     | t.v AND t.v OR t2.v | t.v OR t.v AND t2.v |
+-------+-------+---------------------+---------------------+
| true  | true  | true                | true                |
| true  | false | true                | true                |
| true  |       | true                | true                |
| false | true  | false               | false               |
| false | false | false               | false               |
| false |       | false               | false               |
|       | true  |                     |                     |
|       | false |                     |                     |
|       |       |                     |                     |
+-------+-------+---------------------+---------------------+

Describe alternatives you've considered

No response

Additional context

No response

@eejbyfeldt eejbyfeldt added the enhancement New feature or request label Oct 5, 2024
@eejbyfeldt eejbyfeldt changed the title Improvce boolean simplifications for nullable fields Improve boolean simplifications for nullable fields Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant