fix: return error instead of capacity overflow panic in generate_series#22323
Queued
sweb wants to merge 2 commits into
Queued
fix: return error instead of capacity overflow panic in generate_series#22323sweb wants to merge 2 commits into
sweb wants to merge 2 commits into
Conversation
9f39638 to
62bc4a4
Compare
2010YOUY01
reviewed
May 18, 2026
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
Captured in issue description
What changes are included in this PR?
Bounds the element count at
isize:MAX / size_of::<i64>()ingenerate_range_valuesand returns a DataFusion execution error when the limit is exceeded, so the function returns a normal DataFusion error instead of panicking insideVec::reserve.Only the scalar UDF path path in
datafusion/functions-nested/src/range.rsis affected, the table-valued generate_series already streams and is unchanged.This PR just takes care of the panic and does not attempt a larger refactor towards streaming or introducing a max-elements config value. Happy to follow up on either.
Are these changes tested?
Added sqllogictest to tests in
datafusion/sqllogictest/test_files/array/array_range.sltto cover the issues presented in the issue.Are there any user-facing changes?
Queries that previously crashed the process with capacity overflow now returns
Execution error: Range too large to materialize: would produce {count} elements ({MAX_RANGE_ELEMENTS})Behavior for valid ranges is unchanged.