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 when they explicitly opt out of view types with datafusion.sql_parser.map_string_types_to_utf8view=false and datafusion.execution.parquet.schema_force_view_types=false.
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.
Is your feature request related to a problem or challenge?
left,right, andsubstrcurrently returnUtf8Vieweven when their first argument isUtf8orLargeUtf8.This makes these functions inconsistent with other string-producing functions such as
lower,upper,reverse,translate, andsubstr_index, which preserve the first argument's string type. It also means users cannot keepUtf8flowing through these functions even when they explicitly opt out of view types withdatafusion.sql_parser.map_string_types_to_utf8view=falseanddatafusion.execution.parquet.schema_force_view_types=false.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 producesUtf8Viewand then downstream code has to add explicit casts back toUtf8.Describe the solution you'd like
Make
left,right, andsubstrpreserve the first argument's string type:Utf8 -> Utf8LargeUtf8 -> LargeUtf8Utf8View -> Utf8ViewThis matches the behavior of
lower/upperand still keeps the optimized view-array path forUtf8Viewinputs.Describe alternatives you've considered
The current behavior was introduced for performance because
Utf8Viewcan 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
substroptimization. The goal is not to removeUtf8Viewsupport, but to avoid forcing it when callers useUtf8/LargeUtf8input.