From 0098435f8338d7a9838bb13426c0e9dfac6c5248 Mon Sep 17 00:00:00 2001 From: Vladimir Kochergin Date: Wed, 20 Aug 2025 18:10:05 +0200 Subject: [PATCH] feat(engine/dolphin): implement MATCH_AGAINST conversion in SQL AST (#1192, #3091) * add conversion logic for MATCH_AGAINST statements * create type casting for search terms to 'text' * construct A_Expr for MATCH_AGAINST operation --- internal/engine/dolphin/convert.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/internal/engine/dolphin/convert.go b/internal/engine/dolphin/convert.go index 64606665a9..33b89ae8f4 100644 --- a/internal/engine/dolphin/convert.go +++ b/internal/engine/dolphin/convert.go @@ -989,7 +989,30 @@ func (c *cc) convertLockTablesStmt(n *pcast.LockTablesStmt) ast.Node { } func (c *cc) convertMatchAgainst(n *pcast.MatchAgainst) ast.Node { - return todo(n) + searchTerm := c.convert(n.Against) + + stringSearchTerm := &ast.TypeCast{ + Arg: searchTerm, + TypeName: &ast.TypeName{ + Name: "text", // Use 'text' type which maps to string in Go + }, + Location: n.OriginTextPosition(), + } + + matchOperation := &ast.A_Const{ + Val: &ast.String{Str: "MATCH_AGAINST"}, + } + + return &ast.A_Expr{ + Name: &ast.List{ + Items: []ast.Node{ + &ast.String{Str: "AGAINST"}, + }, + }, + Lexpr: matchOperation, + Rexpr: stringSearchTerm, + Location: n.OriginTextPosition(), + } } func (c *cc) convertMaxValueExpr(n *pcast.MaxValueExpr) ast.Node {