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

Add additional simplification rules #1406

Closed
alamb opened this issue Dec 6, 2021 · 1 comment · Fixed by #4200
Closed

Add additional simplification rules #1406

alamb opened this issue Dec 6, 2021 · 1 comment · Fixed by #4200
Labels
enhancement New feature or request

Comments

@alamb
Copy link
Contributor

alamb commented Dec 6, 2021

As pointed out by @xudong963 on #1376, there are several other rewrite rules we could add following the pattern in simplify:

A AND !(A) --> false (if A is not nullable)

Note that if A is null (or some expresson that could be null), then A AND !(A) is NULL

Similarly,

A * 0 --> 0 (if A is not nullable)

The "is nullable" bit is somewhat tricky -- and to be honest I am not sure our current code handles all such cases correctly either.

@Jefffrey
Copy link
Contributor

Jefffrey commented Nov 14, 2022

A * 0 --> 0 (if A is not nullable)

Is already implemented:

https://github.com/apache/arrow-datafusion/blob/b58ec81ab06af7a267ee69b834715727dbef963d/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs#L580-L591

A AND !(A) --> false (if A is not nullable)

Implemented by #4200

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.

2 participants