Repository navigation
fix(plan): project shared CTE output before publication - #30636
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
|
mo-bot review · Commit: Review belongs to an older commit; it is not a review of the current head. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 796eed89b5150edcfba98b1a5da9cdd5c17d8e18
Assessment: approve
Reviewed the complete eight-file delta and affected planner/compiler paths. The explicit projection restores shared CTE publication order while preserving required child evaluation and excluding foreign-key row-image sinks. Ownership, cleanup and compatibility remain coherent; no actionable defects found.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1
Validation:
-
Reconciled the frozen head, clean source, complete patch and changed-file fingerprints. Static audit passed: checks/1792489257994951149-3.json and review-audit-v2.log under the assigned attempt directory. The earlier audit failure was solely the exported patch's omitted final newline.
-
Reused exact-head CI snapshot successes for shared build, Ubuntu/x86 UT, Linux/arm64 SCA, UT coverage, Compose PROXY BVT and Compose PESSIMISTIC BVT.
-
Inspected planner schema/ordinal assertions, compiler value and error tests, orphan cleanup, streaming fallback and legacy-sink exclusions. Reviewed SQL/result coverage for distinct SUM/MAX values, asymmetric readers, NULL/empty input, prepared reuse, INSERT SELECT and ROLLUP.
-
Performance tracing found bounded column-projection work only for nonidentity shared CTE layouts; ordinary column vectors are borrowed, and narrowed publication reduces downstream materialization volume. Identity layouts add no operator.
-
Detailed review and evidence reconciliation retained in /home/xupeng/.local/state/mo-bot/jobs/0160ffdc80bd72b7714c102a/attempt-1/review-notes.txt.
Limitations:
-
No fresh Go/native/SQL tests or benchmarks were run. Supplied CI evidence contains terminal summaries rather than individual test logs; author-reported local runs have no retained receipts in local_validation.
-
The linked issue's independent body was not supplied; its behavioral contract was assessed from the frozen PR description and regression SQL.
Merge Queue Status
This pull request spent 4 hours 7 minutes 14 seconds in the queue, with no time running CI. ReasonPull request #30636 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.
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. Waiting for any of
All conditions
Tick the box to put this pull request back in the merge queue (same as
|
aptend
left a comment
There was a problem hiding this comment.
Deep-reviewed the complete eight-file change at exact head 796eed8 against base/merge-base 309f618, issue #30141 and all review/discussion history. No blocking issue found.
The publication projection is inserted at the remapping owner, after the wider child's required evaluations, and SINK metadata becomes identity references at the compacted width/types. Actual shared-CTE creation, rather than the generic CTESinkOption tag, gates the new operator, preserving foreign-key row-image and recursive/legacy layouts. Traced positional readers, projection removal, compiler consumers, materialized fanout and streaming fallback. Reviewed the independent typed-plan and actual-value/error/orphan tests and all SQL/golden changes.
Lifecycle audit:
| Contract | Closure |
|---|---|
| Ownership | Projection borrows child vectors; source owns publication clones; merge owns reader clones; executor/source/reader cleanup stays paired. |
| Wait termination | Existing source notification, producer Finish(error), context cancellation and compile-owner close remain reachable; the projection adds no wait. |
| Bounds | New metadata is query-sized, projection is column-bounded, and materialization retains its existing memory/spill admission and release limits. |
Reused exact-head terminal evidence after reading raw logs/artifacts: UT 118514406109 and normal coverage 118514409034 pass; SCA 118514408749 reports zero issues. The formerly affected functional-index cascade and repeated-alias cascade/SET NULL public test roots pass. PROXY BVT 118514410162 explicitly reports projection_pruning.sql 53/53, update_multi_target_modern.sql 309/309, fk_issue_26831.sql 36/36, and update_modern_fk.sql 190/190, with no failed/ignored statements. No duplicate local build/test or product edits were needed; author-reported local same-instance reruns are not presented as fresh reviewer executions.
…ef58979cbd7e89284d67df963853a587d7414dd
…ef58979cbd7e89284d67df963853a587d7414dd
What type of PR is this?
Which issue(s) this PR fixes:
The issue remains open after merge for verification by the reporter.
What this PR does / why we need it:
A shared aggregate CTE over
(g,h,v)=(1,7,10)can return(1,10,10)instead of(1,7,7)when readers selectMAX(h)and omit the precedingSUM(v).This follows #30145. Readers use the compacted logical SINK schema, but the producer can retain extra computations to preserve their error semantics. Publishing that wider child batch makes a reader fetch SUM at the ordinal intended for MAX.
At the planner's column-remapping boundary, add an explicit PROJECT before a shared CTE SINK when its publication schema differs from the evaluated child. Track the actual shared CTE sinks created by CTE reuse so this projection is paired with positional remapping of all readers. Other sources also use CTESinkOption, including foreign-key maintenance row images; their established layouts must remain intact. The compiler consumes the explicit plan and does not interpret SINK metadata as another executable projection.
Validation on macOS arm64, Go 1.27.1 with the repository CGo test wrapper:
pkg/sql/planandpkg/sql/compilepackages, focused public SQL integration tests, incrementalgo vet, configured golangci-lint and formatting checks pass.cte/projection_pruning.sqland all three failed CI SQL files:update_multi_target_modern.sql,fk_issue_26831.sqlandupdate_modern_fk.sql. Database teardown is checked between rounds. CTE cases include distinct SUM/MAX values, asymmetric readers, NULL/empty/multiple groups, prepared reuse, INSERT SELECT and ROLLUP.Identity layouts need no additional operator. Nonidentity shared CTE layouts reuse the existing projection executor with bounded per-batch column work. No wire or storage format changes. Linux/x64 multi-CN CI will run on the updated head.