Skip to content

feat: implement LEAD() and LAG() window functions (#1216)#2491

Open
imsanupm wants to merge 1 commit intoAlaSQL:developfrom
imsanupm:fix/window-functions-1216
Open

feat: implement LEAD() and LAG() window functions (#1216)#2491
imsanupm wants to merge 1 commit intoAlaSQL:developfrom
imsanupm:fix/window-functions-1216

Conversation

@imsanupm
Copy link
Copy Markdown

@imsanupm imsanupm commented May 4, 2026

Description

Partial fix for #1216

Implements LEAD() and LAG() window offset functions with full
PARTITION BY and ORDER BY support.

Syntax Supported

LEAD(col, offset, default) OVER (PARTITION BY col ORDER BY col)
LAG(col, offset, default) OVER (PARTITION BY col ORDER BY col)

Changes

  • src/424select.js — detect LEAD/LAG functions and store config
    in query.windowoffsets
  • src/40select.js — post-process LEAD/LAG after query execution,
    grouping rows by partition and applying offset logic
  • src/55functions.js — register LEAD/LAG as stub functions
    (actual logic handled in post-processing)
  • test/test-1216-lead-lag.js — regression tests covering LAG,
    LEAD, default values, and custom offsets

Tests

  • 4 new regression tests all passing
  • All 2449 existing tests still passing

@mathiasrw
Copy link
Copy Markdown
Member

mathiasrw commented May 5, 2026

It looks like you have pushed the wrong commit.

image

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.

2 participants