Repository navigation
fix: canonicalize CHAR window keys - #28106
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? |
aptend
left a comment
There was a problem hiding this comment.
Reviewed exact head e3a940f.
The window-only CHAR key canonicalization preserves projected values while aligning PARTITION BY, peer ranking, and RANGE ordering with PAD SPACE semantics. The comparison cast remains covered by the mixed-version MORPC gate, and the optimizer total-cast extension is non-shrinking and charset-preserving.
Validation: git diff --check; go test ./pkg/sql/plan -count=1; focused comparison-cast tests in ./pkg/sql/plan/function; go vet ./pkg/sql/plan; clean merge-tree against current main.
|
Queued — the merge queue status continues in this comment ↓. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed exact head e3a940f9fdba3fc738ed446c2943f6ae19ced93e.
Blocking: please remove the unrelated singleRowCastIsTotal expansion at pkg/sql/plan/opt_misc.go:1846-1852, or split it into a separately justified and tested change.
This PR's contract is window-key canonicalization, but this hunk independently broadens primary-key GROUP BY aggregate elimination for every non-shrinking CHAR/VARCHAR/TEXT cast. singleRowCastIsTotal is a safety proof used when replacing a blocking Aggregate with a streaming Project, so a new true domain needs its own positive and nearest-negative coverage (source/target OID, width boundary, charset mismatch, unbounded width, and TINYTEXT byte-width behavior). The new return true at line 1852 is not executed even by the full ./pkg/sql/plan suite.
The hunk is also not needed for this fix: I temporarily removed only these eight lines and both the exact window regression and the complete owning-package suite still passed. Keeping an unneeded optimizer semantic expansion in a correctness fix makes its risk and regression contract invisible.
The window-specific part otherwise held under counterexamples for direct/derived/CTE/named-window/explicit-CHAR keys, preserved width/charset/nullability, and left a plain VARCHAR control unwrapped. Existing exact-head CI is green.
Validation performed: git diff --check; focused changed tests; full ./pkg/sql/plan; line coverage inspection; temporary counterexample tests (all through the repository CGo wrapper). The review worktree was restored clean afterward.
aunjgr
left a comment
There was a problem hiding this comment.
Verified the direct CHAR counterexample against the issue contract. The window-only PAD SPACE key cast preserves ordinary predicate binding, covers partition, rank, and RANGE peers, and the public control matches GROUP BY and explicit VARCHAR behavior. CI is complete and green.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed exact head 536e4f7b2ff60487c0d0e8656b284d1a6ef1ca03 after the prior changes request. The new commit removes the unrelated singleRowCastIsTotal optimizer expansion in full; the window-only CHAR PAD SPACE canonicalization is otherwise unchanged. Direct and promoted CHAR keys are covered across PARTITION BY, ranking peers, and RANGE frames, with GROUP BY and explicit VARCHAR controls. The cast is scoped to window keys, preserves the projected value path, and adds only constant planner work per key. Exact-head CI is complete and green.
Merge Queue Status
This pull request spent 13 seconds in the queue, including 1 second running CI. Required conditions to merge
|
fix: canonicalize CHAR window keys Approved by: @aptend, @XuPeng-SH, @aunjgr
fix: canonicalize CHAR window keys Approved by: @aptend, @XuPeng-SH, @aunjgr
fix: canonicalize CHAR window keys Approved by: @aptend, @XuPeng-SH, @aunjgr
What type of PR is this?
Which issue(s) this PR fixes:
issue #28023
What this PR does / why we need it:
fix: canonicalize CHAR window keys