Preserve string slice function return types#23330
Draft
xudong963 wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
left,right, andsubstrcurrently always returnUtf8View, even when their first argument isUtf8orLargeUtf8. This makes them inconsistent with nearby string-producing functions such aslower,upper,reverse,translate, andsubstr_index, which preserve the first argument's string type.The unconditional
Utf8Viewreturn type also means callers that intentionally avoid view types cannot keepUtf8flowing through these functions without explicit casts back toUtf8, 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 PR revisits the performance tradeoff from #21441 / #21442 and makes these functions follow the same input-driven return-type contract as the other string functions.
What changes are included in this PR?
left,right, andsubstrreturn type inference to use the first argument's string type.StringArray/LargeStringArrayforUtf8/LargeUtf8inputs.StringViewArraypath forUtf8Viewinputs.Utf8,LargeUtf8, andUtf8Viewreturn types.Are these changes tested?
Yes. I ran:
Are there any user-facing changes?
Yes.
left,right, andsubstrnow preserve the first argument's string type:Utf8 -> Utf8LargeUtf8 -> LargeUtf8Utf8View -> Utf8ViewThis may remove implicit downstream casts for users that expect
Utf8, but it also meansUtf8/LargeUtf8inputs no longer use the previous zero-copyUtf8Viewresult representation.