xudong963 opened a new issue, #23329: URL: https://github.com/apache/datafusion/issues/23329
### Is your feature request related to a problem or challenge? `left`, `right`, and `substr` currently return `Utf8View` even when their first argument is `Utf8` or `LargeUtf8`. This makes these functions inconsistent with other string-producing functions such as `lower`, `upper`, `reverse`, `translate`, and `substr_index`, which preserve the first argument's string type. It also means users cannot keep `Utf8` flowing through these functions even if SQL string literals are planned as `Utf8` and schema view coercion is disabled. This is especially surprising for systems that intentionally avoid view types at API or materialization boundaries: a query such as `substr(utf8_col, 1, 3)` silently produces `Utf8View` and then downstream code has to add explicit casts back to `Utf8`. ### Describe the solution you'd like Make `left`, `right`, and `substr` preserve the first argument's string type: - `Utf8 -> Utf8` - `LargeUtf8 -> LargeUtf8` - `Utf8View -> Utf8View` This matches the behavior of `lower` / `upper` and still keeps the optimized view-array path for `Utf8View` inputs. ### Describe alternatives you've considered The current behavior was introduced for performance because `Utf8View` can represent slices without copying for regular string input. Another possible design would be an explicit configuration option, but the return type of scalar functions is currently not configuration-driven, so input-driven return types are simpler and consistent with nearby string functions. ### Additional context This revisits the tradeoff from #21441 / #21442 and the similar `substr` optimization. The goal is not to remove `Utf8View` support, but to avoid forcing it when callers use `Utf8` / `LargeUtf8` input. -- 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]
