comphead commented on code in PR #672:
URL: https://github.com/apache/datafusion-comet/pull/672#discussion_r1683353001
##########
native/core/src/execution/datafusion/planner.rs:
##########
@@ -541,6 +542,24 @@ impl PhysicalPlanner {
Some(self.create_expr(case_when.else_expr.as_ref().unwrap(), input_schema)?)
}
};
+
+ // optimized path for CASE WHEN predicate THEN expr ELSE null
END
+ if else_phy_expr.is_none() && when_then_pairs.len() == 1 {
+ let when_then = &when_then_pairs[0];
+ // CaseWhenExprOrNull is only safe to use for expressions
that do not
+ // have side effects, and it is only suitable to use for
expressions
+ // that are inexpensive to compute (such as a column
reference)
+ // because it will be evaluated for all rows in the batch
rather
+ // than just the rows where the predicate is true.
+ // For now, we limit the use to raw column references
+ if when_then.1.as_any().is::<Column>() {
+ return Ok(Arc::new(CaseWhenExprOrNull::new(
+ when_then.0.clone(),
Review Comment:
```suggestion
Arc::clone(&when_then.0),
Arc::clone(&when_then.1),
```
--
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]