Repository navigation
feat(frontend-sql): model SQL window frame clauses (ROWS/RANGE BETWEEN ...) - #270
Merged
Merged
Conversation
…N ...) SQLWindowFunc previously dropped the frame clause entirely — a default frame, ROWS BETWEEN 2 PRECEDING AND CURRENT ROW, and ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING all lowered to identical IR, so every frame-sensitive window function (SUM, AVG, COUNT, MIN, MAX, FIRST_VALUE, LAST_VALUE, NTH_VALUE) with a non-default frame was silently wrong. Adds WindowFrame/WindowFrameUnits/WindowFrameBound to the canonical IR and threads it through lowering, CSE, resolve, and DAG export. GROUPS frames are rejected explicitly (unused in this repo's SQL corpora, unsupported downstream). Fixes #268 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
milindsrivastava1997
force-pushed
the
issue-268-window-frame
branch
from
August 24, 2026 02:25
738aabd to
2267f65
Compare
Contributor
|
Fixed the review findings in commit What changed:
Validation: |
This was referenced Aug 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SQLWindowFuncpreviously dropped the window-frame clause entirely. A default frame,ROWS BETWEEN 2 PRECEDING AND CURRENT ROW, andROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWINGtherefore lowered to structurally identical IR.WindowFrame,WindowFrameUnits,WindowFrameBound, and typedWindowFrameOffsetvalues to the canonical IR.lower_windownow preserves DataFusion's resolved frame, including its context-dependent default.RANGE ... INTERVALbounds are normalized to month/day/nanosecond components instead of remaining opaque DataFusion 43 strings such as"1 HOUR".SQLWindowFuncnodes that predate the frame field remain readable through#[serde(default)] frame: Option<WindowFrame>; newly lowered SQL always producesSome(frame).These defaults follow DataFusion's documented behavior: with
ORDER BY, the default ends at the current row; withoutORDER BY, it covers the entire partition.Noneis reserved for legacy IR because one static fallback could not reconstruct both cases safely.Before / after IR
Example:
Before — no machine-readable frame:
After — the resolved frame is part of the IR:
An interval RANGE bound is typed as:
for
INTERVAL '1' HOUR.Scope
ROWSandRANGEare modeled.GROUPSis explicitly rejected rather than silently mis-lowered. DataFusion supports it, but it remains outside this PR's declared scope.Tests
window_frame_is_captured_not_droppedrange_interval_frame_is_preservedgroups_frame_is_rejectedlegacy_window_json_without_frame_deserializes_as_unspecifiedcargo test -p asap-frontend-sql -p asap-typesformat-and-lintandtestFixes #268