findepi commented on issue #11413:
URL: https://github.com/apache/datafusion/issues/11413#issuecomment-2347153946
> it will both create and allocate a new temporary `String` for each row
(and then presumably copy that value into a final StringArray/LargeStringArray).
>
> ```rust
> // declare concat
> #[function("concat(string, string) -> string")]
> #[function("concat(largestring, largestring) -> largestring")]
> fn concat(lhs: &str, rhs: &str) -> String {
> format!("{}{}", lhs, rhs)
> }
> ```
I understand we're not concerned whether `format!` is the best way to
concatenate two strings, but more about the fundamental fact that `concat`
function allocates and returns a new `String` object every time.
I don't know how does `#[function]` macro work, but I assume it generates a
ColumnarValue processor that handles ScalarValue directly and an Array value
with a for loop. For the for loop code branch, is the compiler capable of
optimizing away the `concat`'s allocation?
--
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]