Skip to content

fix: lag i64::MIN offset overflow#22338

Open
chakkk309 wants to merge 2 commits into
apache:mainfrom
chakkk309:fix-lag-i64-min-offset
Open

fix: lag i64::MIN offset overflow#22338
chakkk309 wants to merge 2 commits into
apache:mainfrom
chakkk309:fix-lag-i64-min-offset

Conversation

@chakkk309
Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

lead / lag normalize offsets internally by negating values in some cases. When the offset is i64::MIN, negating it overflows because i64::MIN cannot be represented as a positive i64.

This can trigger an overflow panic instead of returning a proper DataFusion error.

What changes are included in this PR?

This PR rejects i64::MIN offsets for lead / lag before they can be negated.

It adds checked offset negation logic and returns an execution error like:

lag offset must not be i64::MIN

Are these changes tested?

Yes

Are there any user-facing changes?

Yes

@github-actions github-actions Bot added the functions Changes to functions implementation label May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic: lag window function negates i64::MIN offset during execution

1 participant