Skip to content

test: move lead/lag extreme-offset regressions to sqllogictest#377

Open
Dandandan wants to merge 2 commits into
mainfrom
codex/fix-issues-22231-and-22221-in-datafusion-u6i295
Open

test: move lead/lag extreme-offset regressions to sqllogictest#377
Dandandan wants to merge 2 commits into
mainfrom
codex/fix-issues-22231-and-22221-in-datafusion-u6i295

Conversation

@Dandandan

Copy link
Copy Markdown
Owner

Motivation

  • Ensure extreme lead/lag offset regressions are validated at the SQL-level (sqllogictest) rather than as Rust unit tests to match review guidance and exercise the public execution path.
  • Prevent panics and overflow from extreme offsets by keeping the earlier evaluator fixes (safe negation and checked arithmetic) in place and ensuring behavior is observable from SQL tests.

Description

  • Change WindowShiftKind::shift_offset to return Result<i64> and use checked_neg() for lead to reject i64::MIN with a descriptive execution error.
  • Update partition_evaluator to propagate the Result and apply reversal for reversed evaluators.
  • Replace unchecked index arithmetic in WindowShiftEvaluator::evaluate with checked subtraction and safe usize conversion to avoid overflow/panic for extreme offsets.
  • Remove two Rust unit tests that asserted the extreme-offset behaviors and add datafusion/sqllogictest/test_files/lead_lag_extreme_offsets.slt which covers both cases at the SQL level: lead(value, -9223372036854775808, 0) produces an execution error and lead(value, 9223372036854775807, 0) returns the provided default for all rows.

Testing

  • Ran cargo fmt --all, which completed successfully.
  • Ran cargo clippy --all-targets --all-features -- -D warnings, which failed due to a pre-existing, unrelated compile error in datafusion/physical-plan/benches/aggregate_vectorized.rs.
  • Attempted targeted SQL-level test with cargo test -p datafusion-sqllogictest --test sqllogictests -- lead_lag_extreme_offsets, but a full build/run could not be completed in this environment due to heavy compilation and build locking; recommend CI to run the new sqllogictest file during PR validation.

Codex Task

@Dandandan Dandandan force-pushed the codex/fix-issues-22231-and-22221-in-datafusion-u6i295 branch from b7f84ae to e6ccbda Compare May 16, 2026 10:22
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant