Skip to content

Commit 5ec3094

Browse files
kyleconroyclaude
andcommitted
Handle DISTINCT modifier in parametric function calls
For parametric aggregate functions like groupArraySample(5, 11111)(DISTINCT x), the DISTINCT modifier was being parsed as a column name instead of being recognized as a modifier. This adds DISTINCT/ALL handling to parseParametricFunctionCall matching the existing logic in parseFunctionCall. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 04d68a5 commit 5ec3094

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

parser/expression.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2598,6 +2598,19 @@ func (p *Parser) parseParametricFunctionCall(fn *ast.FunctionCall) *ast.Function
25982598

25992599
p.nextToken() // skip (
26002600

2601+
// Handle DISTINCT modifier (but not if DISTINCT is being used as a column name)
2602+
// If DISTINCT is followed by ) or , then it's a column reference, not a modifier
2603+
if p.currentIs(token.DISTINCT) && !p.peekIs(token.RPAREN) && !p.peekIs(token.COMMA) {
2604+
result.Distinct = true
2605+
p.nextToken()
2606+
}
2607+
2608+
// Handle ALL modifier (but not if ALL is being used as a column name)
2609+
// If ALL is followed by ) or , then it's a column reference, not a modifier
2610+
if p.currentIs(token.ALL) && !p.peekIs(token.RPAREN) && !p.peekIs(token.COMMA) {
2611+
p.nextToken()
2612+
}
2613+
26012614
// Parse the actual arguments
26022615
if !p.currentIs(token.RPAREN) {
26032616
result.Arguments = p.parseExpressionList()
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt8": true
4-
}
5-
}
1+
{}

0 commit comments

Comments
 (0)