Skip to content

Commit 34afcd4

Browse files
wawan93Vladimir Kochergin
andauthored
feat(engine/dolphin): implement MATCH_AGAINST conversion in SQL AST (#1192, #3091) (#4070)
* add conversion logic for MATCH_AGAINST statements * create type casting for search terms to 'text' * construct A_Expr for MATCH_AGAINST operation Co-authored-by: Vladimir Kochergin <[email protected]>
1 parent ded5342 commit 34afcd4

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

internal/engine/dolphin/convert.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,30 @@ func (c *cc) convertLockTablesStmt(n *pcast.LockTablesStmt) ast.Node {
989989
}
990990

991991
func (c *cc) convertMatchAgainst(n *pcast.MatchAgainst) ast.Node {
992-
return todo(n)
992+
searchTerm := c.convert(n.Against)
993+
994+
stringSearchTerm := &ast.TypeCast{
995+
Arg: searchTerm,
996+
TypeName: &ast.TypeName{
997+
Name: "text", // Use 'text' type which maps to string in Go
998+
},
999+
Location: n.OriginTextPosition(),
1000+
}
1001+
1002+
matchOperation := &ast.A_Const{
1003+
Val: &ast.String{Str: "MATCH_AGAINST"},
1004+
}
1005+
1006+
return &ast.A_Expr{
1007+
Name: &ast.List{
1008+
Items: []ast.Node{
1009+
&ast.String{Str: "AGAINST"},
1010+
},
1011+
},
1012+
Lexpr: matchOperation,
1013+
Rexpr: stringSearchTerm,
1014+
Location: n.OriginTextPosition(),
1015+
}
9931016
}
9941017

9951018
func (c *cc) convertMaxValueExpr(n *pcast.MaxValueExpr) ast.Node {

0 commit comments

Comments
 (0)