You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/04/07 02:10:11 UTC

[GitHub] [arrow-datafusion] liukun4515 commented on a diff in pull request #2171: minor: Avoid per cell evaluation in Coalesce, use zip in CaseWhen

liukun4515 commented on code in PR #2171:
URL: https://github.com/apache/arrow-datafusion/pull/2171#discussion_r844573204


##########
datafusion/physical-expr/src/conditional_expressions.rs:
##########
@@ -35,36 +33,51 @@ pub fn coalesce(args: &[ColumnarValue]) -> Result<ColumnarValue> {
         )));
     }
 
-    let size = match args[0] {
-        ColumnarValue::Array(ref a) => a.len(),
-        ColumnarValue::Scalar(ref _s) => 1,
-    };
-    let mut res = new_null_array(&args[0].data_type(), size);
+    let return_type = args[0].data_type();
+    let mut return_array = args.iter().filter_map(|x| match x {
+        ColumnarValue::Array(array) => Some(array.len()),
+        _ => None,

Review Comment:
   why not use the same logic by returning `Some(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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org