Skip to content

Commit c9defb8

Browse files
committed
Add TRIM function FROM keyword and function COLLATE support
- Handle TRIM(chars FROM string) syntax where FROM acts as parameter separator instead of comma - Add COLLATE clause support for function calls in parsePostExpressionAccess Enables Baselines140_TrimBuiltInTest140
1 parent 85a7a86 commit c9defb8

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

parser/parse_select.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,7 @@ func (p *Parser) parseFunctionCallFromIdentifiers(identifiers []*ast.Identifier)
13841384
}
13851385

13861386
// Parse parameters
1387+
funcNameUpper := strings.ToUpper(fc.FunctionName.Value)
13871388
if p.curTok.Type != TokenRParen {
13881389
for {
13891390
param, err := p.parseScalarExpression()
@@ -1392,6 +1393,12 @@ func (p *Parser) parseFunctionCallFromIdentifiers(identifiers []*ast.Identifier)
13921393
}
13931394
fc.Parameters = append(fc.Parameters, param)
13941395

1396+
// Special handling for TRIM function: FROM keyword acts as separator
1397+
if funcNameUpper == "TRIM" && strings.ToUpper(p.curTok.Literal) == "FROM" {
1398+
p.nextToken() // consume FROM
1399+
continue
1400+
}
1401+
13951402
if p.curTok.Type != TokenComma {
13961403
break
13971404
}
@@ -1587,6 +1594,13 @@ func (p *Parser) parsePostExpressionAccess(expr ast.ScalarExpression) (ast.Scala
15871594
fc.OverClause = overClause
15881595
}
15891596

1597+
// Check for COLLATE clause for function calls
1598+
if fc, ok := expr.(*ast.FunctionCall); ok && strings.ToUpper(p.curTok.Literal) == "COLLATE" {
1599+
p.nextToken() // consume COLLATE
1600+
fc.Collation = p.parseIdentifier()
1601+
continue
1602+
}
1603+
15901604
break
15911605
}
15921606

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}

0 commit comments

Comments
 (0)