Skip to content

Commit 9a0b0ad

Browse files
committed
Fix window frame keywords being parsed as implicit aliases
The PARTITION BY clause in window functions was incorrectly consuming window frame keywords like ROWS, RANGE, GROUPS as implicit aliases. This broke window function parsing for queries like: SELECT abs(number) over (partition by x rows unbounded preceding) Added window frame keywords to the exclusion list in parseImplicitAlias: - ROWS, RANGE, GROUPS (frame type) - UNBOUNDED, PRECEDING, FOLLOWING, CURRENT (frame bounds)
1 parent 443aba5 commit 9a0b0ad

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

parser/expression.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ func (p *Parser) parseImplicitAlias(expr ast.Expression) ast.Expression {
180180
if upper == "INTERSECT" {
181181
return expr
182182
}
183+
// Don't consume window frame keywords as implicit aliases
184+
switch upper {
185+
case "ROWS", "RANGE", "GROUPS", "UNBOUNDED", "PRECEDING", "FOLLOWING", "CURRENT":
186+
return expr
187+
}
183188
alias := p.current.Value
184189
p.nextToken()
185190

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"explain_todo": {
3-
"stmt12": true,
43
"stmt3": true
54
}
65
}

parser/testdata/01591_window_functions/metadata.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"stmt38": true,
2121
"stmt39": true,
2222
"stmt41": true,
23-
"stmt45": true,
2423
"stmt50": true,
2524
"stmt51": true,
2625
"stmt52": true,
@@ -39,7 +38,6 @@
3938
"stmt77": true,
4039
"stmt78": true,
4140
"stmt79": true,
42-
"stmt8": true,
4341
"stmt80": true,
4442
"stmt81": true,
4543
"stmt82": true,

0 commit comments

Comments
 (0)