Skip to content

Format window frame clauses separately from ORDER BY in DuckDB and T-SQL - #1004

Closed
obaseyi2 wants to merge 8 commits into
sql-formatter-org:masterfrom
obaseyi2:fix/window-frame-clause
Closed

obaseyi2 wants to merge 8 commits into
sql-formatter-org:masterfrom
obaseyi2:fix/window-frame-clause

Conversation

@obaseyi2

@obaseyi2 obaseyi2 commented Oct 24, 2026 •

Copy link
Copy Markdown

Fixes #892.

DuckDB and T-SQL treat a window frame as part of the preceding ORDER BY expression and break its bounds at AND.

Classify ROWS BETWEEN and RANGE BETWEEN as frame clauses in these dialects, plus GROUPS BETWEEN in DuckDB. Keep the bounds' AND inline; ordinary boolean AND formatting is unchanged.

SELECT
  sum(size) OVER (
    ORDER BY
      time_stamp
    ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
  )
FROM
  some_events;

Regressions cover frame types, idempotence and tabular indentation. Both reported-layout tests failed before the fix.

Validation on the published head: 27 Jest suites passed (5,892 tests passed, 1 skipped, 63 snapshots); repository-wide formatting, lint, type checking and CJS/ESM/webpack builds passed.

Local tools were installed separately on Windows/Node 24 without lockfile changes; CI uses Node 22. Other dialects retain their current frame layout. Classification remains lexical, consistent with these dialects' existing clause handling.

@nene

nene commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

I assume this is AI generated. It's no good. I don't want to spend time explaining why, as you probably didn't spend much time in implementing this.

@nene nene closed this Oct 29, 2026
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.

In a window clause, "ROWS BETWEEN ..." should start a new line, it's not part of ORDER BY

2 participants