alamb commented on code in PR #17628:
URL: https://github.com/apache/datafusion/pull/17628#discussion_r2379649731


##########
datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs:
##########
@@ -1409,6 +1409,47 @@ impl<S: SimplifyInfo> TreeNodeRewriter for 
Simplifier<'_, S> {
                 Transformed::yes(*then_)
             }
 
+            // Remove WHEN false clauses and handle WHEN true optimizations
+            Expr::Case(Case {
+                expr: None,
+                when_then_expr,
+                else_expr,
+            }) if !when_then_expr.is_empty() => {

Review Comment:
   Yes, I think so
   
   In general I think we could combine this branch with the one above (that 
checks for a single `true` clause) 🤔 
   
   So the logic would be
   * if the `WHEN` exprs have any true or false literals 
   * then rewrite the when_then expr, removing all `false` literals and any 
arms after the first `true`
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to