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] ROLLUP ORDER BY GROUPING fails with wrapped selected grouping keys #26269
WITH ROLLUP fails when grouping columns are wrapped only for display in the select list while ORDER BY directly uses GROUPING() and the original grouping columns.
Version
MatrixOne main at 4f82ab5476a798bb1c61903abf77a29a2f6c4fc8.
Reproduction
CREATETABLErollup_audit (
region varchar(8),
product varchar(8),
amount int
);
INSERT INTO rollup_audit VALUES
('east', 'a', 10),
('east', 'b', 20),
('west', 'a', 30),
(NULL, 'a', 5);
SELECT
COALESCE(region, '<null>'),
COALESCE(product, '<null>'),
SUM(amount),
GROUPING(region),
GROUPING(product)
FROM rollup_audit
GROUP BY region, product WITH ROLLUP
ORDER BY GROUPING(region), region, GROUPING(product), product;
Actual behavior
MatrixOne returns:
ERROR 20301 (HY000): invalid input: column region does not exist
The result reproduces in three independent executions.
Expected behavior
The query should return the base groups, subtotals, and grand total. Local MySQL accepts the same SQL and returns eight rows. The GROUPING() values distinguish the source NULL group from the rollup rows.
Scope
The base ROLLUP query succeeds. The query also succeeds when either the display wrappers or the ORDER BY clause is removed. The failure requires their combination.
Activity
fix(plan): preserve ROLLUP source order keys (#26357)
Ariznawlll commentedon Aug 10, 2026
测试版本
main3c7392a0f86b23712da71f31d7a9198a2c8591a9原问题验证
原始带显示包装、
GROUPING()和ORDER BY的 ROLLUP SQL 连续执行 3 次,均返回 8 行(明细、两级小计、总计),不再报column region does not exist。Happy Path 覆盖
COALESCE显示包装、原始分组键排序和两个GROUPING()标记。Unhappy Path 覆盖
白盒验证
不适用:使用公开 SQL 语义黑盒验证。
回归测试
已加入 motr PR #89 的
suites/14_issue_regression/t/issue_26269_25973_25389_25327_25326_sql_semantics.test(commita6a50dfcf7053027dab5e9117fde7bdd7b5cdefb)。测试证据
MOTR 连续 3 轮:关联 5 个场景合计 15/15 成功、171 条断言成功。
测试结论
测试通过。
fix(plan): preserve ROLLUP source order keys (matrixorigin#26357)
fix(plan): preserve ROLLUP source order keys (matrixorigin#26357)
fix(plan): preserve ROLLUP source order keys (matrixorigin#26357)