Repository navigation
Description
Branch and commit
- Branch:
main - Commit:
d5c4e8b832ad0275766f6d8f8f0be7ec4c0fb544 - Environment: local two-CN MatrixOne; each case was executed through both CN SQL ports.
Problem
A top-level MATCH() AGAINST() predicate can be served by a FULLTEXT or FULLTEXT2 index. Adding a normal window function to the same select prevents that rewrite. The planner leaves fulltext_match(...) on a base-table scan, and execution returns ERROR 20105 because a full table scan cannot evaluate MATCH.
This is separate from the previously closed IN-subquery case: the MATCH predicate here is directly in the query block's WHERE clause; the only additional relational operator is ROW_NUMBER().
Reproduction
SET experimental_fulltext2_index = 1;
CREATE TABLE docs (
id BIGINT PRIMARY KEY,
body TEXT,
v VECF32(3),
FULLTEXT2 ft(body) WITH PARSER ngram
);
INSERT INTO docs VALUES
(1,'alpha','[0,0,0]'),
(2,'beta','[0.1,0,0]'),
(3,'alpha','[0.2,0,0]'),
(4,'alpha','[0.3,0,0]');
ALTER TABLE docs ALTER REINDEX ft FULLTEXT2 FORCE_SYNC;
-- This returns 1,3,4.
SELECT id FROM docs
WHERE MATCH(body) AGAINST('alpha' IN BOOLEAN MODE)
ORDER BY id;
-- This is rejected with ERROR 20105.
SELECT id,
ROW_NUMBER() OVER (ORDER BY l2_distance(v,'[0,0,0]'), id) AS rn
FROM docs
WHERE MATCH(body) AGAINST('alpha' IN BOOLEAN MODE)
ORDER BY id;The same result occurs with classic FULLTEXT INDEX ft(body) WITH PARSER ngram, with the corresponding experimental_fulltext_index session setting.
Observed plan
Project
-> Sort
-> Window
-> Table Scan on docs
Filter Cond: fulltext_match('alpha', 3, docs.body)
There is no fulltext2_search/fulltext_index_scan table function, so the unreplaced MATCH reaches execution and returns:
ERROR 20105 (HY000): not supported: MATCH() AGAINST() function cannot be replaced by FULLTEXT INDEX and full table scan with fulltext search is not supported yet.
Scope and controls
- FULLTEXT2: three freshly-created databases; after synchronous reindex, direct MATCH returned
1,3,4on both CNs; the window query returned the same 20105 on both CNs in all three runs. - Classic FULLTEXT: three freshly-created databases; direct MATCH returned
1,3,4on both CNs; the window query returned the same 20105 on both CNs in all three runs. - Without MATCH, the same
ROW_NUMBER()expression returned1:1,2:2,3:3,4:4on both CNs in all six databases.
Expected behavior
The MATCH predicate should still be rewritten to the available fulltext index beneath the window operator, so the query returns (1,1), (3,2), and (4,3).
Activity
Ariznawlll commentedon Sep 17, 2026
在固定的 current-main
01d60e1c4ded1b0f3fc1a4ecd75ce54e95e23b90上扩展了窗口边界,问题仍存在,并且范围不只限于原复现中的ROW_NUMBER():ROW_NUMBER() OVER (ORDER BY id)、COUNT(*) OVER()、分区COUNT(*) OVER(PARTITION BY grp)、LAG()均使同一查询块内的裸WHERE MATCH(...)留在基表扫描并返回 20105;WHERE MATCH(...) > 0的 wrapped predicate 同样不能穿过 Window 节点完成改写;MATCHscore 排序时也返回 20105;可用的结构性对照进一步缩小了问题位置:先在内层 CTE/derived query 完成全文检索,再在外层执行 Window,可以正确返回
1,2,4,6;按 score 排序的行号也正确。因此索引内容、score 计算和 Window 算子本身均正常,缺口是同一 query block 内Window -> Project -> Scan(MATCH)形态没有把 MATCH 改写放到 Window 之前。新增覆盖的代表 SQL:
这仍是 #28974 的同一 planner traversal 缺口,不另提重复 issue。该问题适合 planner UT + 小数据 SQL 回归,不需要 big-data 或 chaos。
test(fulltext): add classic FULLTEXT window+MATCH BVT (matrixorigin#2…
test(plan): cover replaceScoreFnInExprBy Expr_W traversal for coverag…
fix(plan): serve fulltext MATCH under WINDOW+PARTITION and propagate …
test(fulltext2): accept WHERE MATCH + window in view DDL, mirroring t…
fix(plan): rewrite served MATCH copies in WINDOW.FilterList (matrixor…
fix(plan): rewrite served fulltext MATCH in an independent FILTER abo…
fix(plan): rewrite MATCH beneath a window operator and OUTER JOIN to …
Ariznawlll commentedon Sep 22, 2026
测试版本
main3727c5c5436ca136d7b0312f75bc223a11692a85原问题验证
在窗口算子上层使用 FULLTEXT
MATCH ... AGAINST过滤已能正确执行,不再因 MATCH 未重写到窗口算子下方而失败。Happy Path 覆盖
匹配返回 id
1,3,4,row_number()为1,2,3,MATCH score 计算正确。Unhappy Path 覆盖
覆盖无匹配文本和布尔模式过滤,确认不产生漏行、重复行或窗口序号错乱。
白盒验证
同时执行 classic FULLTEXT 与 fulltext2 两条实现路径,验证 MATCH 谓词和 score 穿过窗口算子的计划语义一致。
回归测试
新增
suites/14_issue_regression/t/issue_28974_fulltext_window_match.test,已提交至 motr#199。测试证据
定向用例连续执行 3 轮;本次新增 7 个 case 共执行 21 次,结果为
21/21通过。14_issue_regression整套执行时该用例也通过。MOTR 当前未为该分支上报远端 checks。测试结论
测试通过。