Repository navigation
[4.1.6-hotfix] fix(plan): deduplicate grouping NULL values in DISTINCT - #32802
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? |
|
This pull request is merged. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Approved after reviewing b51540a against 4.1.6-hotfix on 10.222.1.57.
The final DISTINCT boundary materializes nullable selected columns without mutating upstream grouping provenance or converting stored values. I checked the shared VALUES caller, vector reuse and NULL/grouping ownership, ORDER BY resolution, and the FLOAT and GEOMETRY revalidation counterexamples. On 57, the focused planner and function tests passed, including the typed keys, constant/NULL/empty vectors, repeated evaluation, and existing VALUES tests. The public SQL/CTAS coverage and the author's two normal BVT runs provide complementary evidence. There were no unresolved human review comments at review time.
This adds a vector copy for nullable selected keys at this boundary; no production-scale performance claim is made. CI currently reports failed UT/SCA jobs with incomplete step records; this approval does not assert those checks passed or identify their cause.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #32789
What this PR does / why we need it:
Global DISTINCT over grouping-extension results can hash actual NULL and subtotal NULL as different values because transported columns still carry the internal grouping bitmap. This leaves duplicate visible NULL rows in ENUM/SET SELECT results and CTAS readback.
VALUESscalar. Copy the stored values, exact types and NULL bits, and clear only the result's grouping bitmap without mutating the input.Validation on macOS arm64 with Go 1.26.4:
pkg/sql/planandpkg/sql/plan/functiontest packages pass through the CGo test wrapper.grouping_ctas.sqlpasses twice on the same isolated single-CN instance: 391/391 statements each time. Database/table teardown and geometry-session-setting restoration checks pass.func_geometry.test: 763/763 pass. Existingon_duplicate_key.sql: 139 pass, 8 existing skips, no failures.No new function ID, protocol, catalog or persisted-format changes. Multi-CN and repository-wide SCA were not run.