Skip to content

Commit eed1e73

Browse files
committed
allow aggregate/window functions with match expressions
1 parent 2269c83 commit eed1e73

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

enginetest/queries/script_queries.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11687,6 +11687,32 @@ select * from t1 except (
1168711687
},
1168811688
},
1168911689
},
11690+
{
11691+
Name: "aggregate function with match",
11692+
SetUpScript: []string{
11693+
"CREATE TABLE test (pk INT PRIMARY KEY, doc TEXT, FULLTEXT idx (doc));",
11694+
"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');",
11695+
},
11696+
Assertions: []ScriptTestAssertion{
11697+
{
11698+
// https://github.com/dolthub/dolt/issues/9761
11699+
Skip: true,
11700+
Query: "SELECT pk, count(pk), MATCH(doc) AGAINST('aaaa') AS relevancy FROM test ORDER BY relevancy DESC;",
11701+
// TODO: replace with corresponding error once validation for aggregated query without group by
11702+
// has been implemented https://github.com/dolthub/dolt/issues/9761
11703+
ExpectedErr: nil,
11704+
},
11705+
{
11706+
Query: "SET SESSION sql_mode = REPLACE(@@SESSION.sql_mode, 'ONLY_FULL_GROUP_BY', '');",
11707+
Expected: []sql.Row{{types.NewOkResult(0)}},
11708+
},
11709+
11710+
{
11711+
Query: "SELECT pk, count(pk), MATCH(doc) AGAINST('aaaa') AS relevancy FROM test ORDER BY relevancy DESC;",
11712+
Expected: []sql.Row{{1, 4, float64(0)}},
11713+
},
11714+
},
11715+
},
1169011716
}
1169111717

1169211718
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)