-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Eliminate Unsatisfiable Boolean Expressions #1716
Comments
On a related note it is unable to simplify expressions of the form
|
Related to this, I think the PoC @pjmore extended this optimizer to be able to optimize both expressions and logical plan nodes. |
I'm not at all familiar with e-graphs, but I would perhaps naively expect something specialised to boolean algebra to significantly out-perform a method based on arbitrary expression rewriting? I guess I'm thinking something like BDDs, or even just recursively applying shannon expansion and relying on const propagation to fix the mess... This isn't an area I'm hugely familiar with, but I can't help feeling it should just be the case of picking an off-the-shelf boolean expression minimizer and plugging it in 😅 FWIW a quick google search found this - https://docs.rs/boolean_expression/latest/boolean_expression/index.html |
I do wonder if https://docs.rs/boolean_expression/latest/boolean_expression/index.html handles |
FWIW alamb=# select null AND (not null);
?column?
----------
(1 row) |
We can do this rewrite
|
Does something similar also hold for things like |
Yes. In fact @NGA-TRAN fixed a bug related to that in #1245 -- I think we have it sufficiently tested now. See some of the rules here It actually turn out that However, 🤯 |
Aah yes, the SQL interpretation of NULL as "unknown" vs perhaps more intuitive notions of it... 😅
|
It's depend on #2254 |
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
I noticed Datafusion is not able to simplify the expression
Whilst it is unlikely for a user to write such an expression, it is not uncommon for boolean expressions to reduce to something unsatisfiable. Where this is the case, substituting in
false
may allow for further simplification.Describe the solution you'd like
It would be awesome if Datafusion was able to detect and eliminate unsatisfiable boolean expressions. I believe this is an NP-hard problem in the general case, but should be tractable for a low number of variables.
The text was updated successfully, but these errors were encountered: