Repository navigation
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.
Important
Fork CI setup: For pull requests from a fork to
main, enable workflows in your fork's Actions tab before you push.See the fork CI setup guide.
Which issue does this PR close?
Closes #27623.
Rationale for this change
In
repeaton standard ArrowUtf8string arrays (datafusion/functions/src/string/repeat.rs), each row's repeated length was capped ati32::MAXbytes, but the cumulative total across all rows in a batch was not bounded before passingtotal_capacityintoGenericStringArrayBuilder::<i32>::with_capacity.When an array contains multiple rows whose combined output exceeds
i32::MAX(2,147,483,647 bytes), the builder attempts a multi-gigabyte buffer allocation upfront and triggers an offset overflow panic ("byte array offset overflow") upon appending values because standard ArrowUtf8offsets are 32-bit signed integers (i32).PR #26957 previously fixed the equivalent cumulative overflow issue for
LargeUtf8(LARGE_UTF8_MAX_SIZE), but standardUtf8remained vulnerable when multiple rows combined to exceedi32::MAX.What changes are included in this PR?
repeat()under theUtf8match arm:DataFusionError::Executionbefore any builder memory is allocated.LargeUtf8check and error message format.Utf8Viewuncapped, as it supports multi-buffer allocation without a 2 GiB offset limit.What is the testing strategy for this PR?
Added two deterministic, memory-safe unit tests in
datafusion/functions/src/string/repeat.rs:test_repeat_string_array_total_exceeds_max_size: Large array (131,072 rows) where each row is withini32::MAXbut the cumulative total exceedsi32::MAX. Fails immediately before builder buffer allocation (< 1 ms runtime).test_repeat_string_array_total_overflow_small_batch: Two rows of ~1 GiB each totallingi32::MAX + 1bytes, verifying exact off-by-one boundary rejection.Are there any user-facing changes?
No breaking changes. Queries calling
repeatonUtf8arrays whose cumulative result exceedsi32::MAXwill now cleanly return aDataFusionError::Executioninstead of panicking or aborting the process.