andygrove commented on code in PR #12049:
URL: https://github.com/apache/datafusion/pull/12049#discussion_r1723695089


##########
datafusion/physical-expr/src/expressions/case.rs:
##########
@@ -150,6 +155,35 @@ impl CaseExpr {
                 && else_expr.as_ref().unwrap().as_any().is::<Literal>()
             {
                 EvalMethod::ScalarOrScalar
+            } else if when_then_expr.len() == 1
+                && when_then_expr[0].0.as_any().is::<BinaryExpr>()
+            {
+                let b = when_then_expr[0]
+                    .0
+                    .as_any()
+                    .downcast_ref::<BinaryExpr>()
+                    .expect("expected binary expression");
+
+                if b.op().eq(&Operator::Gt) {

Review Comment:
   The check here does not seem to be complete. It would work fine for the 
example `CASE WHEN y > 0 THEN x / y ELSE NULL END` but what about `CASE WHEN y 
> 0 THEN a / b ELSE NULL END`? It would be good to add some tests that call 
`try_new` with different variations and check for the correct eval method.



-- 
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