Skip to content

Implement LEAD, LAG, FIRST_VALUE, LAST_VALUE window functions#2444

Open
apoorvdarshan wants to merge 1 commit intoAlaSQL:developfrom
apoorvdarshan:feat/lead-lag-first-last-value-window-functions
Open

Implement LEAD, LAG, FIRST_VALUE, LAST_VALUE window functions#2444
apoorvdarshan wants to merge 1 commit intoAlaSQL:developfrom
apoorvdarshan:feat/lead-lag-first-last-value-window-functions

Conversation

@apoorvdarshan
Copy link

Summary

  • Implements SQL:2003 positional window functions: LEAD(), LAG(), FIRST_VALUE(), LAST_VALUE() (resolves Window Offset Functions (LEAD/LAG/FIRST_VALUE/LAST_VALUE) Not Implemented #2409)
  • Supports PARTITION BY and ORDER BY in OVER clauses, with configurable offset and default values for LEAD/LAG
  • Adds 16 test cases covering basic usage, partitioning, edge cases (nulls, offset > partition size, DESC ordering, multiple window fns)

Test plan

  • All 16 new tests in test/test2409.js pass
  • Full regression suite passes (2457 passing, 0 failing)
  • Verify LEAD/LAG with explicit offset and custom default values
  • Verify FIRST_VALUE/LAST_VALUE with and without PARTITION BY
  • Verify edge cases: nulls, single-row partitions, offset exceeding partition size

…#2409)

Add support for SQL:2003 positional window functions with PARTITION BY
and ORDER BY. These enable period-over-period comparisons and accessing
relative row values within partitions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Window Offset Functions (LEAD/LAG/FIRST_VALUE/LAST_VALUE) Not Implemented

1 participant