wangrunji0408 commented on issue #11413:
URL: https://github.com/apache/datafusion/issues/11413#issuecomment-2348008054
@findepi
The `#[function]` macro doesn't process `ColumnarValue` as in datafusion.
Instead it always outputs an array value.
A new String object will be allocated if the `concat` function is defined as
above. However, you can prevent this by rewriting the function as follows,
where the result is written directly to the array buffer.
```rust
#[function("concat(string, string) -> string")]
#[function("concat(largestring, largestring) -> largestring")]
fn concat(lhs: &str, rhs: &str, output: &mut impl std::fmt::Write) {
write!(output, "{}{}", lhs, rhs).unwrap();
}
```
--
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]