Omega359 commented on code in PR #20436:
URL: https://github.com/apache/datafusion/pull/20436#discussion_r2853402855
##########
datafusion/functions/src/string/concat.rs:
##########
@@ -88,37 +88,33 @@ impl ScalarUDFImpl for ConcatFunc {
&self.signature
}
+ /// Match the return type to the input types to avoid unnecessary casts. On
+ /// mixed inputs, prefer Utf8View; prefer LargeUtf8 over Utf8 to avoid
+ /// potential overflow on LargeUtf8 input.
fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {
use DataType::*;
- let mut dt = &Utf8;
- arg_types.iter().for_each(|data_type| {
- if data_type == &Utf8View {
- dt = data_type;
- }
- if data_type == &LargeUtf8 && dt != &Utf8View {
- dt = data_type;
- }
- });
-
- Ok(dt.to_owned())
+ if arg_types.contains(&Utf8View) {
+ Ok(Utf8View)
+ } else if arg_types.contains(&LargeUtf8) {
Review Comment:
I had a thought about this. I think LargeUtf8 should take precedence over
Utf8View because you cannot necessarily fit data from a LargeUtf8 column into
Utf8View (i64 vs i32)
https://docs.rs/arrow/latest/arrow/datatypes/enum.DataType.html#variant.LargeUtf8
--
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]