Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Related to closed #26826 (synthesized NULL keys), #26827 (SQL round trip), and #24436. This is a 4.1.6-hotfix validation/backport follow-up. Grouping-extension fixes are being removed from PR #32085 to keep that PR limited to matrixflow #20285's UNION NULL and outer-join CTAS failures.
Branch Name
4.1.6-hotfix
Commit ID
Target base 77052f8d1f9e6833ff5e5b41ae2343b5bcf0d152. Investigation/fix history is retained in unmerged commit 1dd2bf61082bd4740e8069e82ccf44e228b3245e and its parent.
Other Environment Information
Investigation used Go 1.26.4, a matching isolated single-CN MO service and planner/parser tests. The issues linked above have separate main-branch reproduction evidence; this report does not claim a fresh exact-base reproduction of every grouping variant.
Actual Behavior
The release branch still needs a coherent grouping-extension closure:
- Missing grouping-set output keys must be nullable without mutating the evaluated input types.
- CTAS formats its source into INSERT SQL; empty/duplicate GROUPING SETS and CUBE syntax must survive that round trip.
- Rebinding an expanded ROLLUP/CUBE AST must not expand it again from a partial/empty subset. During PR investigation, repeated planning expanded ROLLUP group count 3→5; CUBE rebind lost original keys and produced
must appear in the GROUP BY clause. - Real SQL validation exposed correct-looking metadata with missing subtotal rows, so planner metadata tests alone are insufficient.
Expected Behavior
View/CTAS metadata and actual subtotal rows must agree. Parse/format/reparse and repeated planning must preserve original keys, explicit duplicate/empty grouping sets and grouping multiplicities. Ordinary GROUP BY and keys present in every grouping set retain their existing non-null contract.
Steps to Reproduce
CREATE TABLE src(g INT NOT NULL,h INT NOT NULL,v INT NOT NULL);
INSERT INTO src VALUES(1,10,5),(1,20,7),(2,10,9);
SELECT g,h,SUM(v) FROM src GROUP BY g,h WITH ROLLUP;
CREATE TABLE r AS SELECT g,h,SUM(v) s FROM src GROUP BY g,h WITH ROLLUP;
CREATE TABLE c AS SELECT COALESCE(g,-1) g,COALESCE(h,-1) h,SUM(v) s
FROM src GROUP BY CUBE(g,h);
CREATE TABLE s AS SELECT COALESCE(g,-1) g,COALESCE(h,-1) h,SUM(v) s
FROM src GROUP BY GROUPING SETS ((g,h),(g),());Compare each source SELECT with CTAS rows/schema and explicit INSERT into a nullable pre-created target. Separately parse one AST and plan it three times; require stable grouping count and generated SQL. Preserve explicit duplicate grouping sets rather than globally deduplicating groups.
Additional information
The unmerged implementation/test history contains TestGroupByFormatRoundTrip, TestCreateTableAsSelectGroupingRebind and real SQL controls. Revalidate them on the chosen branch base rather than blindly cherry-picking the larger CTAS/MARK patch. The old hint_cte fixture expects repeated ROLLUP subtotals; if rebinding is repaired, independently verify its ten correct rows before updating that expectation. That fixture change belongs to this follow-up, not the narrowed #20285 PR.
No production replay or production data-loss claim. Keep this work separate from the general function-proof and MARK resource/performance follow-ups.
Activity
fix(plan): preserve CTAS output nullability on 4.1.6 hotfix (#32085)
fix(plan): close grouping-set review regressions
fix(plan): preserve grouping output and global window boundaries
fix(plan): preserve grouping-extension CTAS semantics on 4.1.6-hotfix (…
slyunnn commentedon Nov 18, 2026
Regression and extended verification for #32265 (2026-11-18)
Verification Environment
4.1.6-hotfixat latest fetched52da59083ff60beab943d347c187f568fc5c84aa,[4.1.6-hotfix] fix(plan): deduplicate grouping NULL values in DISTINCT (#32802); the binary reports52da59083fon all three endpoints.34691aecbb58a297d4cf7fdc1e69694126f20f4e, preserves grouping-extension nullability, SQL round trips and repeated planning. PR [4.1.6-hotfix] fix(plan): deduplicate grouping NULL values in DISTINCT #32802 subsequently fixes the related DISTINCT NULL boundary.2 CN / 1 TN / 1 Log / Proxy; Proxy6001, CN116001and CN216002were all reachable and the original and expanded SQL ran on each through the MySQL protocol via PyMySQL. Product BVT ran via JDBC on Proxy. Tests ran serially and do not establish engine-parallel or production performance behavior.What Was Covered
ROLLUPSELECT and CTAS produce the independently expected six rows and nullable grouping keys on all three endpoints;CUBEand duplicateGROUPING SETSreturn the expected values and multiplicities.function/grouping_ctas.sqlpasses391/391, including explicit INSERT, CTAS schema and nullable constraints,CUBE, duplicate and empty grouping sets, views, repeated prepared execution, actual versus synthesized NULL and result-boundary checks.TestGroupByFormatRoundTripandTestGroupingRepeatedPlanningpass, covering parser formatting/reparsing and repeated planning. Each endpoint remains healthy after the SQL checks.Findings
The tested source SELECT, CTAS rows and nullable-key metadata agree; duplicate grouping sets retain their multiplicity.
MOTR / BVT Coverage
The existing product BVT and focused parser/planner tests directly cover the reported scenarios, so a duplicate MOTR case is unnecessary. This hotfix is outside the currently maintained MOTR
mainand4.2-devtargets.Final Conclusion
Fixed on
4.1.6-hotfixat52da59083ffor the tested scope.