Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
Description
In HIVE-14431 jcamachorodriguez proposed a simplification for CASE when all branches are not nullable boolean expression into an alternative AND/OR/NOT based expression. This allows for more aggressive reductions and split/push-down on the whole. Meantime the simplifier code migrated to Calcite so I'm reviving this here.
The proposed simplification is:
CASE WHEN p1 THEN ex1 WHEN p2 THEN ex2 ... WHEN pn THEN exn ELSE TRUE/FALSE END
to be transformed into:
(p1 AND ex1) OR (not(p1) AND p2 AND x2) ... OR (not(p1) AND not(p2) ... AND not(pn-1) AND Pn AND exn) [OR (not(p1) AND not(p2) ... AND not(pn))]
The last OR is depending on the ELSE branch being TRUE/FALSE.
Attachments
Issue Links
- is related to
-
CALCITE-1290 When converting to CNF, fail if the expression size exceeds a threshold
- Closed
- relates to
-
CALCITE-1794 Expressions with numeric comparisons are not simplified when CAST is present
- Closed