Repository navigation
fix(plan): preserve ROLLUP source order keys - #26357
Conversation
Merge Queue Status
This pull request spent 11 minutes 13 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #26357 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
Failing checks:
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Tick the box to put this pull request back in the merge queue (same as
|
…6418) This reverts squash commit `538a45b37d7162182734c943c59bbbd723da3508` from #26331 at the author request. The revert removes the multi-reference CTE reuse planner, query-scoped materialized source and spill path, and the associated compile/Dispatch/Merge wiring as one complete unit. Multi-reference CTEs return to independent inline planning, and sink scans use the existing streaming pipeline path. The revert is synchronized with current `upstream/main` (`2c9608dd45960126ff3a91fc3bbb0addd53d816d`). Later overlapping fixes #26357 and #26393 remain present. There is no SQL syntax, protobuf, public API, or persistence-format change. ### Validation Exact head `fb1b16f27b9665203197678f385815755b143b06`: - previous head `d693b810af44d4d9f0ae22ad3b18d68e78e6dc06`: all major functional CI jobs passed; Matrixone Utils Coverage alone failed because modified-line coverage was exactly 75%, while the gate requires strictly greater than 75% - added `TestDispatchResetSkipsInvalidRemoteReceiversAndNotifiesHealthyPeer`, covering both nil receiver and nil error-channel guards while proving that a later healthy receiver still receives the original terminal error - focused coverprofile: `pkg/sql/colexec/dispatch/types.go:227.33,234.14` changed from count 0 in CI to count 1 locally - exact-head remote Coverage: PASS with 4/4 modified lines covered (`pr_coverage=1.0`, threshold `>0.75`) - affected planner/compile/dispatch/merge package tests: PASS - complete affected owning packages under `-race -count=1`: PASS - focused dispatch terminal and compile sink-scan tests under `-race -count=20`: PASS - affected package build and vet: PASS - `git diff --check`: PASS - exact reverse/overlap audit: only later #26357 and #26393 edits remain relative to the #26331 parent - schema-v4 preflight: `PASS review=PASS validation=PASS` BVT: the previous exact-head Proxy multi-CN and pessimistic BVT jobs passed. This follow-up adds package-internal unit coverage only and does not change product behavior. ### QA decision QA required: yes. This rolls back optimizer selection and the materialized fan-out execution path. CI and environment-level analytical-query regression coverage should complete before merge. Approved by: @XuPeng-SH
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26269 ## What this PR does / why we need it: ROLLUP, CUBE, and GROUPING SETS are expanded into an internal UNION ALL. ORDER BY expressions containing GROUPING() were already materialized as hidden branch projections, but ordinary source grouping columns were left to bind above the union. When the visible select list wrapped those columns for display, the original source columns were no longer available and planning failed with `column ... does not exist`. This change: - materializes source-dependent non-DISTINCT grouping-set order keys while branch bindings are still available; - reuses visible projections when an ORDER BY expression matches a selected expression, including after star expansion, so expressions are not evaluated twice; - preserves ORDER BY alias precedence, DISTINCT restrictions, positional ordering, and the final output schema; - adds planner coverage for ROLLUP, CUBE, GROUPING SETS, aliases, visible-expression reuse, hidden source keys, and DISTINCT, plus a distributed ROLLUP regression case with source NULL values. Validation: - `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=20m ./pkg/sql/plan` - `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=20m ./pkg/sql/plan` - `go build -mod=readonly ./pkg/sql/plan/...` - `go vet -mod=readonly ./pkg/sql/plan/...` - `make static-check` - rollup BVT: 162 passed, 0 failed, 2 ignored - `git diff --check` --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…#26331)" (matrixorigin#26418) This reverts squash commit `538a45b37d7162182734c943c59bbbd723da3508` from matrixorigin#26331 at the author request. The revert removes the multi-reference CTE reuse planner, query-scoped materialized source and spill path, and the associated compile/Dispatch/Merge wiring as one complete unit. Multi-reference CTEs return to independent inline planning, and sink scans use the existing streaming pipeline path. The revert is synchronized with current `upstream/main` (`2c9608dd45960126ff3a91fc3bbb0addd53d816d`). Later overlapping fixes matrixorigin#26357 and matrixorigin#26393 remain present. There is no SQL syntax, protobuf, public API, or persistence-format change. ### Validation Exact head `fb1b16f27b9665203197678f385815755b143b06`: - previous head `d693b810af44d4d9f0ae22ad3b18d68e78e6dc06`: all major functional CI jobs passed; Matrixone Utils Coverage alone failed because modified-line coverage was exactly 75%, while the gate requires strictly greater than 75% - added `TestDispatchResetSkipsInvalidRemoteReceiversAndNotifiesHealthyPeer`, covering both nil receiver and nil error-channel guards while proving that a later healthy receiver still receives the original terminal error - focused coverprofile: `pkg/sql/colexec/dispatch/types.go:227.33,234.14` changed from count 0 in CI to count 1 locally - exact-head remote Coverage: PASS with 4/4 modified lines covered (`pr_coverage=1.0`, threshold `>0.75`) - affected planner/compile/dispatch/merge package tests: PASS - complete affected owning packages under `-race -count=1`: PASS - focused dispatch terminal and compile sink-scan tests under `-race -count=20`: PASS - affected package build and vet: PASS - `git diff --check`: PASS - exact reverse/overlap audit: only later matrixorigin#26357 and matrixorigin#26393 edits remain relative to the matrixorigin#26331 parent - schema-v4 preflight: `PASS review=PASS validation=PASS` BVT: the previous exact-head Proxy multi-CN and pessimistic BVT jobs passed. This follow-up adds package-internal unit coverage only and does not change product behavior. ### QA decision QA required: yes. This rolls back optimizer selection and the materialized fan-out execution path. CI and environment-level analytical-query regression coverage should complete before merge. Approved by: @XuPeng-SH
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26269 ## What this PR does / why we need it: ROLLUP, CUBE, and GROUPING SETS are expanded into an internal UNION ALL. ORDER BY expressions containing GROUPING() were already materialized as hidden branch projections, but ordinary source grouping columns were left to bind above the union. When the visible select list wrapped those columns for display, the original source columns were no longer available and planning failed with `column ... does not exist`. This change: - materializes source-dependent non-DISTINCT grouping-set order keys while branch bindings are still available; - reuses visible projections when an ORDER BY expression matches a selected expression, including after star expansion, so expressions are not evaluated twice; - preserves ORDER BY alias precedence, DISTINCT restrictions, positional ordering, and the final output schema; - adds planner coverage for ROLLUP, CUBE, GROUPING SETS, aliases, visible-expression reuse, hidden source keys, and DISTINCT, plus a distributed ROLLUP regression case with source NULL values. Validation: - `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=20m ./pkg/sql/plan` - `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=20m ./pkg/sql/plan` - `go build -mod=readonly ./pkg/sql/plan/...` - `go vet -mod=readonly ./pkg/sql/plan/...` - `make static-check` - rollup BVT: 162 passed, 0 failed, 2 ignored - `git diff --check` --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…#26331)" (matrixorigin#26418) This reverts squash commit `538a45b37d7162182734c943c59bbbd723da3508` from matrixorigin#26331 at the author request. The revert removes the multi-reference CTE reuse planner, query-scoped materialized source and spill path, and the associated compile/Dispatch/Merge wiring as one complete unit. Multi-reference CTEs return to independent inline planning, and sink scans use the existing streaming pipeline path. The revert is synchronized with current `upstream/main` (`2c9608dd45960126ff3a91fc3bbb0addd53d816d`). Later overlapping fixes matrixorigin#26357 and matrixorigin#26393 remain present. There is no SQL syntax, protobuf, public API, or persistence-format change. ### Validation Exact head `fb1b16f27b9665203197678f385815755b143b06`: - previous head `d693b810af44d4d9f0ae22ad3b18d68e78e6dc06`: all major functional CI jobs passed; Matrixone Utils Coverage alone failed because modified-line coverage was exactly 75%, while the gate requires strictly greater than 75% - added `TestDispatchResetSkipsInvalidRemoteReceiversAndNotifiesHealthyPeer`, covering both nil receiver and nil error-channel guards while proving that a later healthy receiver still receives the original terminal error - focused coverprofile: `pkg/sql/colexec/dispatch/types.go:227.33,234.14` changed from count 0 in CI to count 1 locally - exact-head remote Coverage: PASS with 4/4 modified lines covered (`pr_coverage=1.0`, threshold `>0.75`) - affected planner/compile/dispatch/merge package tests: PASS - complete affected owning packages under `-race -count=1`: PASS - focused dispatch terminal and compile sink-scan tests under `-race -count=20`: PASS - affected package build and vet: PASS - `git diff --check`: PASS - exact reverse/overlap audit: only later matrixorigin#26357 and matrixorigin#26393 edits remain relative to the matrixorigin#26331 parent - schema-v4 preflight: `PASS review=PASS validation=PASS` BVT: the previous exact-head Proxy multi-CN and pessimistic BVT jobs passed. This follow-up adds package-internal unit coverage only and does not change product behavior. ### QA decision QA required: yes. This rolls back optimizer selection and the materialized fan-out execution path. CI and environment-level analytical-query regression coverage should complete before merge. Approved by: @XuPeng-SH
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26269 ## What this PR does / why we need it: ROLLUP, CUBE, and GROUPING SETS are expanded into an internal UNION ALL. ORDER BY expressions containing GROUPING() were already materialized as hidden branch projections, but ordinary source grouping columns were left to bind above the union. When the visible select list wrapped those columns for display, the original source columns were no longer available and planning failed with `column ... does not exist`. This change: - materializes source-dependent non-DISTINCT grouping-set order keys while branch bindings are still available; - reuses visible projections when an ORDER BY expression matches a selected expression, including after star expansion, so expressions are not evaluated twice; - preserves ORDER BY alias precedence, DISTINCT restrictions, positional ordering, and the final output schema; - adds planner coverage for ROLLUP, CUBE, GROUPING SETS, aliases, visible-expression reuse, hidden source keys, and DISTINCT, plus a distributed ROLLUP regression case with source NULL values. Validation: - `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=20m ./pkg/sql/plan` - `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=20m ./pkg/sql/plan` - `go build -mod=readonly ./pkg/sql/plan/...` - `go vet -mod=readonly ./pkg/sql/plan/...` - `make static-check` - rollup BVT: 162 passed, 0 failed, 2 ignored - `git diff --check` --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…#26331)" (matrixorigin#26418) This reverts squash commit `538a45b37d7162182734c943c59bbbd723da3508` from matrixorigin#26331 at the author request. The revert removes the multi-reference CTE reuse planner, query-scoped materialized source and spill path, and the associated compile/Dispatch/Merge wiring as one complete unit. Multi-reference CTEs return to independent inline planning, and sink scans use the existing streaming pipeline path. The revert is synchronized with current `upstream/main` (`2c9608dd45960126ff3a91fc3bbb0addd53d816d`). Later overlapping fixes matrixorigin#26357 and matrixorigin#26393 remain present. There is no SQL syntax, protobuf, public API, or persistence-format change. ### Validation Exact head `fb1b16f27b9665203197678f385815755b143b06`: - previous head `d693b810af44d4d9f0ae22ad3b18d68e78e6dc06`: all major functional CI jobs passed; Matrixone Utils Coverage alone failed because modified-line coverage was exactly 75%, while the gate requires strictly greater than 75% - added `TestDispatchResetSkipsInvalidRemoteReceiversAndNotifiesHealthyPeer`, covering both nil receiver and nil error-channel guards while proving that a later healthy receiver still receives the original terminal error - focused coverprofile: `pkg/sql/colexec/dispatch/types.go:227.33,234.14` changed from count 0 in CI to count 1 locally - exact-head remote Coverage: PASS with 4/4 modified lines covered (`pr_coverage=1.0`, threshold `>0.75`) - affected planner/compile/dispatch/merge package tests: PASS - complete affected owning packages under `-race -count=1`: PASS - focused dispatch terminal and compile sink-scan tests under `-race -count=20`: PASS - affected package build and vet: PASS - `git diff --check`: PASS - exact reverse/overlap audit: only later matrixorigin#26357 and matrixorigin#26393 edits remain relative to the matrixorigin#26331 parent - schema-v4 preflight: `PASS review=PASS validation=PASS` BVT: the previous exact-head Proxy multi-CN and pessimistic BVT jobs passed. This follow-up adds package-internal unit coverage only and does not change product behavior. ### QA decision QA required: yes. This rolls back optimizer selection and the materialized fan-out execution path. CI and environment-level analytical-query regression coverage should complete before merge. Approved by: @XuPeng-SH
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #26269
What this PR does / why we need it:
ROLLUP, CUBE, and GROUPING SETS are expanded into an internal UNION ALL. ORDER BY expressions containing GROUPING() were already materialized as hidden branch projections, but ordinary source grouping columns were left to bind above the union. When the visible select list wrapped those columns for display, the original source columns were no longer available and planning failed with
column ... does not exist.This change:
Validation:
.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=20m ./pkg/sql/plan.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=20m ./pkg/sql/plango build -mod=readonly ./pkg/sql/plan/...go vet -mod=readonly ./pkg/sql/plan/...make static-checkgit diff --check