Skip to content

fix: avoid lpad/rpad panic on out-of-range length arrays - #26958

Open
gonappuccino wants to merge 2 commits into
apache:mainfrom
gonappuccino:fix-26949-pad-array-length
Open

gonappuccino wants to merge 2 commits into
apache:mainfrom
gonappuccino:fix-26949-pad-array-length

Conversation

@gonappuccino

Copy link
Copy Markdown

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?

Rationale for this change

lpad/rpad panic or abort when an array length is negative or very large, while a scalar length returns "" or the "too large" error.

What changes are included in this PR?

pad_data_capacity skips lengths outside 0..=i32::MAX and caps the total at i32::MAX. Per-row validation is unchanged.

What is the testing strategy for this PR?

Unit tests in lpad.rs/rpad.rs and sqllogictest cases in string_literal.slt cover negative and very large array lengths.

Are there any user-facing changes?

No.

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Oct 30, 2026
@mbutrovich
mbutrovich self-requested a review November 5, 2026 19:17

@mbutrovich mbutrovich left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gonappuccino for picking this up. Skipping the lengths that parse_target_len turns into "" or an error makes the array path agree with the scalar path, which is what #26949 asks for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lpad and rpad panic or abort on a negative or very large length in an array of lengths

2 participants