Skip to content

Commit ea15fe3

Browse files
committed
Add frame parsing to WINDOW clause definitions
The WINDOW clause parser (parseWindowDefinitions) was missing support for frame specifications (ROWS/RANGE/GROUPS). This meant named window definitions like: WINDOW w1 AS (ROWS UNBOUNDED PRECEDING) would fail to parse correctly. Added frame parsing after ORDER BY in parseWindowDefinitions, matching the logic in parseWindowSpec().
1 parent 9785146 commit ea15fe3

4 files changed

Lines changed: 10 additions & 29 deletions

File tree

parser/parser.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4551,6 +4551,14 @@ func (p *Parser) parseWindowDefinitions() []*ast.WindowDefinition {
45514551
}
45524552
}
45534553

4554+
// Parse frame specification (ROWS/RANGE/GROUPS)
4555+
if p.currentIs(token.IDENT) {
4556+
frameType := strings.ToUpper(p.current.Value)
4557+
if frameType == "ROWS" || frameType == "RANGE" || frameType == "GROUPS" {
4558+
spec.Frame = p.parseWindowFrame()
4559+
}
4560+
}
4561+
45544562
p.expect(token.RPAREN)
45554563
def.Spec = spec
45564564
defs = append(defs, def)

parser/testdata/01591_window_functions/metadata.json

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,6 @@
1111
"stmt110": true,
1212
"stmt111": true,
1313
"stmt112": true,
14-
"stmt31": true,
15-
"stmt34": true,
16-
"stmt35": true,
17-
"stmt36": true,
18-
"stmt37": true,
19-
"stmt38": true,
20-
"stmt39": true,
21-
"stmt41": true,
22-
"stmt50": true,
23-
"stmt51": true,
24-
"stmt52": true,
25-
"stmt53": true,
26-
"stmt54": true,
27-
"stmt55": true,
28-
"stmt56": true,
29-
"stmt57": true,
30-
"stmt69": true,
3114
"stmt70": true,
3215
"stmt71": true,
3316
"stmt72": true,
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt32": true,
4-
"stmt33": true,
5-
"stmt35": true
6-
}
7-
}
1+
{}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt5": true
4-
}
5-
}
1+
{}

0 commit comments

Comments
 (0)