You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: VARIANCE alias cannot be used as a window aggregate #25482
MatrixOne SQL endpoint used for validation: local latest-main build on 127.0.0.1:26001
Actual Behavior
MatrixOne supports var_pop(...) over (...), but the MySQL-compatible alias variance(...) over (...) fails to parse.
MO result:
ERROR 1064 (HY000): SQL parser error: ... syntax error ... near " over (partition by customer_id) ..."
Expected Behavior
MySQL accepts variance(...) over (...) as a window aggregate. It returns the same values as var_pop(...) over (...).
Steps to Reproduce
DROPDATABASE IF EXISTS mysql_compat_window_variance;
CREATEDATABASEmysql_compat_window_variance;
USE mysql_compat_window_variance;
CREATETABLEorders (
id intprimary key,
customer_id int,
amount decimal(10,2)
);
INSERT INTO orders VALUES
(1,10,100.00),(2,10,200.00),(3,10,200.00),
(4,20,NULL),(5,20,150.50),(6,20,150.50),
(7,30,300.00),(8,30,100.00);
SELECT'var_pop' q, id, var_pop(amount) over (partition by customer_id) v
FROM orders ORDER BY id;
SELECT'variance' q, id, variance(amount) over (partition by customer_id) v
FROM orders ORDER BY id;
Additional information
var_pop, var_samp, stddev, stddev_pop, and stddev_samp were also checked as window aggregates on latest main; those parsed and executed successfully. The gap appears specific to the variance alias.
Activity
daviszhen commentedon Jul 30, 2026
fixed
Ariznawlll commentedon Jul 30, 2026
测试版本
main(截至 2026-07-30 16:30,Asia/Shanghai)41332062a6740978f269088a92ee362a888c7bd7etc/launch-with-proxy/launch.toml(2 CN + 1 TN + Proxy),SQL 入口127.0.0.1:6001原问题验证
variance(v) over(partition by g)可解析执行,并逐行与var_pop(v)完全一致;完整黑盒 3/3 通过。Happy Path 覆盖
ROWS BETWEEN 1 PRECEDING AND CURRENT ROW的滑动 frame 结果一致。Unhappy Path 覆盖
白盒验证
TestVarianceWindowSpec连续 3 轮通过;window 全包连续 3 轮及-race通过。回归测试
修复提交
a4389a72f已加入test/distributed/cases/window/mysql_compat_window_variance.sql。测试证据
完整 3 轮 SQL 结果、测试脚本、Proxy 黑盒日志、定向 UT 与
-race输出:https://gist.github.com/Ariznawlll/b8f1a22642a58fd5264482687534728b测试结论
测试通过。
Ariznawlll commentedon Jul 30, 2026
motr 黑盒回归已补充
suites/14_issue_regression/t/issue_25482_window_variance.testmain@41332062a6740978f269088a92ee362a888c7bd7,该批 14 个用例连续 3 轮为 42/42 成功(504/504 语句);完整14_issue_regressionsuite 为 124 成功、0 失败。