comphead commented on code in PR #23660:
URL: https://github.com/apache/datafusion/pull/23660#discussion_r3625888521


##########
datafusion/expr/src/higher_order_function.rs:
##########
@@ -330,61 +330,56 @@ impl LambdaArgument {
         args: &[&dyn Fn() -> Result<ArrayRef>],
         spread_captures: impl FnOnce(&[ArrayRef]) -> Result<Vec<ArrayRef>>,
     ) -> Result<ColumnarValue> {
+        if args.len() < self.params.len() {
+            return exec_err!(
+                "expected at least {} lambda arguments to merge with captures, 
got {}",
+                self.params.len(),
+                args.len()
+            );
+        }
+
+        let args = args
+            .iter()
+            .take(self.params.len())
+            .map(|arg| arg())
+            .collect::<Result<Vec<_>>>()?;
+
+        let row_count = args.first().map(|arg| arg.len()).ok_or_else(|| {
+            exec_datafusion_err!("lambdas with zero parameters are not 
supported")
+        })?;
+
         let spread_captures = self
             .captures
             .as_ref()
+            .filter(|b| !b.columns().is_empty())
             .map(|captures| {
-                let spread_columns = spread_captures(captures.columns())?;
+                let spread_columns = if captures
+                    .schema_ref()
+                    .fields()
+                    .iter()
+                    .all(|f| f.data_type().is_null())
+                {
+                    let null = Arc::new(NullArray::new(row_count)) as _;

Review Comment:
   do we need to calc `null` in loop? 



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