Omega359 commented on code in PR #9040:
URL: https://github.com/apache/arrow-datafusion/pull/9040#discussion_r1470329669
##########
datafusion/physical-expr/src/datetime_expressions.rs:
##########
@@ -497,6 +502,99 @@ pub fn make_current_time(
move |_arg| Ok(ColumnarValue::Scalar(ScalarValue::Time64Nanosecond(nano)))
}
+/// make_date(year, month, date) SQL function implementation
+pub fn make_date(args: &[ColumnarValue]) -> Result<ColumnarValue> {
+ if args.len() != 3 {
+ return exec_err!(
+ "make_date function requires 3 arguments, got {}",
+ args.len()
+ );
+ }
+
+ // first, identify if any of the arguments is an Array. If yes, store its
`len`,
Review Comment:
It's this section in columnar_values_to_array (and the similar bit in
make_scalar_function_with_hints)
```
let args = args
.iter()
.map(|arg| arg.clone().into_array(inferred_length))
.collect::<Result<Vec<_>>>()?;
```
The into_array method seems to eventually percolate down to code like this
in primitive_array.rs
```
/// Creates a PrimitiveArray based on a constant value with `count` elements
pub fn from_value(value: T::Native, count: usize) -> Self {
unsafe {
let val_buf = Buffer::from_trusted_len_iter((0..count).map(|_|
value));
Self::new(val_buf.into(), None)
}
}
```
It was that copy of values into the array that I was attempting to work
around .. which I guess I did at the cost of a cast for every element in the
array. That bit of code is what I was thinking might have been better handled
as a single value array. In any case I'll think about this some more and see
what I can do to optimize this a bit more.
--
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]