Skip to content

Commit 4e1a10a

Browse files
authored
Merge pull request #3187 from dolthub/angela/agg_match
Allow aggregate/window functions with match expressions
2 parents 513d8d4 + 24cfacb commit 4e1a10a

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

enginetest/queries/script_queries.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11687,6 +11687,33 @@ select * from t1 except (
1168711687
},
1168811688
},
1168911689
},
11690+
{
11691+
Name: "aggregate function with match",
11692+
Dialect: "mysql",
11693+
SetUpScript: []string{
11694+
"CREATE TABLE test (pk INT PRIMARY KEY, doc TEXT, FULLTEXT idx (doc));",
11695+
"INSERT INTO test VALUES (2, 'g hhhh aaaab ooooo aaaa'), (1, 'bbbb ff cccc ddd eee'), (4, 'AAAA aaaa aaaac aaaa Aaaa aaaa'), (3, 'aaaA ff j kkkk llllllll');",
11696+
},
11697+
Assertions: []ScriptTestAssertion{
11698+
{
11699+
// https://github.com/dolthub/dolt/issues/9761
11700+
Skip: true,
11701+
Query: "SELECT pk, count(pk), MATCH(doc) AGAINST('aaaa') AS relevancy FROM test ORDER BY relevancy DESC;",
11702+
// TODO: replace with corresponding error once validation for aggregated query without group by
11703+
// has been implemented https://github.com/dolthub/dolt/issues/9761
11704+
ExpectedErr: nil,
11705+
},
11706+
{
11707+
Query: "SET SESSION sql_mode = REPLACE(@@SESSION.sql_mode, 'ONLY_FULL_GROUP_BY', '');",
11708+
Expected: []sql.Row{{types.NewOkResult(0)}},
11709+
},
11710+
11711+
{
11712+
Query: "SELECT pk, count(pk), MATCH(doc) AGAINST('aaaa') AS relevancy FROM test ORDER BY relevancy DESC;",
11713+
Expected: []sql.Row{{1, 4, float64(0)}},
11714+
},
11715+
},
11716+
},
1169011717
}
1169111718

1169211719
var SpatialScriptTests = []ScriptTest{

sql/planbuilder/scalar.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,10 +1015,6 @@ func (b *Builder) ConvertVal(v *ast.SQLVal) sql.Expression {
10151015
// filter, since we only need to load the tables once. All steps after this
10161016
// one can assume that the expression has been fully resolved and is valid.
10171017
func (b *Builder) buildMatchAgainst(inScope *scope, v *ast.MatchExpr) *expression.MatchAgainst {
1018-
// TODO: implement proper scope support and remove this check
1019-
if (inScope.groupBy != nil && inScope.groupBy.hasAggs()) || inScope.windowFuncs != nil {
1020-
b.handleErr(fmt.Errorf("aggregate and window functions are not yet supported alongside MATCH expressions"))
1021-
}
10221018
rts := getTablesByName(inScope.node)
10231019
var rt *plan.ResolvedTable
10241020
var matchTable string

0 commit comments

Comments
 (0)