-
-
Notifications
You must be signed in to change notification settings - Fork 69
Improved window function support #2913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13630,7 +13630,7 @@ over_clause: | |
| } | ||
| | OVER window_name | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| { | ||
| $$.val = &tree.WindowDef{Name: tree.Name($2)} | ||
| $$.val = &tree.WindowDef{RefName: tree.Name($2)} | ||
| } | ||
| | /* EMPTY */ | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What failed: Named-window reference resolution loses ORDER BY/frame behavior for aggregate windows, so inherited and override forms behave like full-partition windows instead of ordered running windows.
Impact · Steps · Stub / mock · Analysis · Why this is likely a bug
t_inherit(id, grp, amt)and insert rows(1,1,10),(2,1,20),(3,1,30),(4,2,5),(5,2,15).SELECT id, SUM(amt) OVER w2 AS s FROM t_inherit WINDOW w1 AS (PARTITION BY grp), w2 AS (w1 ORDER BY id) ORDER BY id;and observe full-partition sums (60,60,60,20,20).SELECT id, SUM(amt) OVER (PARTITION BY grp ORDER BY id) AS s FROM t_inherit ORDER BY id;and observe correct running sums (10,30,60,5,20).go.mod(line 12) togithub.com/dolthub/go-mysql-server v0.20.1-0.20260713191803-1e74a51e8dda. Runtime evidence isolates the defect to named-window resolution: inlineOVER (PARTITION BY grp ORDER BY id)is correct, butOVER w2andOVER (w1 ORDER BY id)both collapse to partition totals. The parser/AST bridge in this repo maps named references throughRefName(postgres/parser/parser/sql.yandserver/ast/window.go), so resolution reaches the planner; the incorrect aggregate behavior is consistent with the changed dependency's named-window merge path keeping an unbounded frame for these reference forms. Smallest practical fix: patch or pin the dependency so named-window merge preserves ORDER BY/frame semantics for inherited/override references, or add a guard in the planning path to avoid promoting these references to an unbounded full-partition frame.Relevant code
go.mod:11-13postgres/parser/parser/sql.y:13631-13634server/ast/window.go:104-107Evidence Package
Copy prompt for an agent