gstvg commented on code in PR #23660:
URL: https://github.com/apache/datafusion/pull/23660#discussion_r3633941680
##########
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:
I'm assuming the `.filter(..).map(..)` above was read as `Iterator` methods,
is that correct? Those are the `Option` ones. I rewrote it to improve
readability and it ended up simpler and smaller
But another part of this patch did allocated a null array in loop, it's
fixed now
https://github.com/apache/datafusion/pull/23660/commits/b61236f145a6f114647ae4351813da6fd7c6e61f
--
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]