CALCITE-1790 Simplify boolean CASE into AND/OR#450
CALCITE-1790 Simplify boolean CASE into AND/OR#450rusanu wants to merge 1 commit intoapache:masterfrom
Conversation
jcamachor
left a comment
There was a problem hiding this comment.
Concerning your question about limiting the number of predicates, I guess we could specify it in terms of number of operands in the CASE statement? This way it would be rather straightforward to bail out quick.
| if (pair.e.getKey().getType().isNullable()) { | ||
| break trueFalse; | ||
| boolean anyNullable = false; | ||
| trueFalse: |
There was a problem hiding this comment.
I think we can kill the trueFalse tag and make the code linear (or maybe I am not reading it properly with the indentation)? It would be more readable, I think after your changes in the method, it does not make sense to have it anymore. 1) Check nullability. 2) Try 2. 3) Try 3.
| @@ -0,0 +1,525 @@ | |||
| /* | |||
There was a problem hiding this comment.
If possible, it would be cool to integrate with existing tests in RexProgramTest instead of adding new infra again, as they already contain multiple tests for CASE (and other preds) simplification.
| pair.e.getKey(), | ||
| pair.e.getValue()), | ||
| false); | ||
| terms.add(simplify(toAdd)); |
There was a problem hiding this comment.
We might miss some simplification if we call simplify at every iteration vs over the returned disjunction (L514), right? (e.g., folding of OR true)
There was a problem hiding this comment.
I moved the simplify to the final disjunction
| // WHEN p3 THEN TRUE | ||
| // ELSE FALSE | ||
| // END | ||
| // if p1...pn cannot be nullable |
There was a problem hiding this comment.
Missing transformation in the comment -> // (p1 or (p3 and not(p2)))
0d7f311 to
3700f54
Compare
|
This seems to risky |
This PR converts the boolean CASE into AND/OR expressions. I did not add any limit atm, will add one but I'm not sure what would be the favorite way (configuration, hard coded) and also what to measure (number of CASE children, complexity of resulted 'simplification?')