viirya commented on code in PR #8962:
URL: https://github.com/apache/arrow-datafusion/pull/8962#discussion_r1463936071
##########
datafusion/physical-expr/src/functions.rs:
##########
@@ -191,6 +191,30 @@ pub(crate) enum Hint {
AcceptsSingular,
}
+/// A helper function used to infer the length of arguments of Scalar
functions and convert
+/// [`ColumnarValue`]s to [`ArrayRef`]s with the inferred length. Note that
this function
+/// only works for functions that accept either that all arguments are scalars
or all arguments
+/// are arrays with same length. Otherwise, it will return an error.
+pub fn process_scalar_func_inputs(args: &[ColumnarValue]) ->
Result<Vec<ArrayRef>> {
+ let len = args
+ .iter()
+ .fold(Option::<usize>::None, |acc, arg| match arg {
+ ColumnarValue::Scalar(_) => acc,
+ ColumnarValue::Array(a) => Some(a.len()),
+ });
Review Comment:
Yea
##########
datafusion/physical-expr/src/functions.rs:
##########
@@ -191,6 +191,30 @@ pub(crate) enum Hint {
AcceptsSingular,
}
+/// A helper function used to infer the length of arguments of Scalar
functions and convert
+/// [`ColumnarValue`]s to [`ArrayRef`]s with the inferred length. Note that
this function
+/// only works for functions that accept either that all arguments are scalars
or all arguments
+/// are arrays with same length. Otherwise, it will return an error.
+pub fn process_scalar_func_inputs(args: &[ColumnarValue]) ->
Result<Vec<ArrayRef>> {
+ let len = args
+ .iter()
+ .fold(Option::<usize>::None, |acc, arg| match arg {
+ ColumnarValue::Scalar(_) => acc,
+ ColumnarValue::Array(a) => Some(a.len()),
+ });
Review Comment:
Yea, nice catch.
--
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]