perf: Optimize string_to_array for scalar args#21131
Open
neilconway wants to merge 3 commits intoapache:mainfrom
Open
perf: Optimize string_to_array for scalar args#21131neilconway wants to merge 3 commits intoapache:mainfrom
string_to_array for scalar args#21131neilconway wants to merge 3 commits intoapache:mainfrom
Conversation
neilconway
commented
Mar 23, 2026
| Ok(()) | ||
| } | ||
|
|
||
| /// String_to_array SQL function |
Contributor
Author
There was a problem hiding this comment.
I had to move some code around to group the string_to_array functions together in the file, sorry for the noisy diff.
neilconway
commented
Mar 23, 2026
| list_builder.append(true); | ||
| } | ||
| (Some(string), None) => { | ||
| string.chars().map(|c| c.to_string()).for_each(|c| { |
Contributor
Author
There was a problem hiding this comment.
This was the inefficient NULL delimiter handling mentioned in the PR summary.
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?
string_to_arrayfor scalar args #21129.Rationale for this change
When the delimiter (and null string, if supplied) are scalars, we can implement
string_to_arraymore efficiently. In particular, we can construct amemmem::Finderand use it to search for delimiters more efficiently.This PR implements this optimization; it also fixes a place where we were allocating an intermediate
Stringfor every character when the delimiter isNULL. (This isn't a common case but worth fixing.)Benchmarks (M4 Max):
What changes are included in this PR?
string_to_arrayAre these changes tested?
Yes.
Are there any user-facing changes?
No.