Repository navigation
fix(compile): deduplicate parallel distinct set results - #27544
mergify[bot] merged 3 commits into
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.
Deep-reviewed exact head 1461404. The final GROUP correctly provides cross-worker deduplication for parallel INTERSECT/MINUS, while the single-scope path and INTERSECT ALL remain unchanged. Full compile tests, focused race runs, go vet, formatting/diff checks, and a clean merge-tree check passed.
|
Queued — the merge queue status continues in this comment ↓. |
Merge Queue Status
This pull request spent 54 minutes 55 seconds in the queue, including 54 minutes 4 seconds running CI. Required conditions to merge
|
…#27544) Parallel `INTERSECT` and `MINUS` execute one distinct set operator per worker. Each worker removes duplicates locally, but the worker outputs were merged without a final global distinct phase. As a result, the same set key could be returned once per worker, causing duplicate rows and incorrect downstream aggregates for ordinary `INTERSECT` / `INTERSECT DISTINCT`. This change extracts the existing `UNION DISTINCT` merge-and-group logic into a shared helper and applies it after parallel `INTERSECT` and `MINUS`. `INTERSECT ALL` and the single-worker path retain their existing behavior. The group expressions remain nullable so NULL set keys preserve SQL distinct semantics. Regression tests verify: - parallel `INTERSECT` and `MINUS` add a global distinct merge; - `INTERSECT ALL` keeps its per-worker results without the distinct merge; - `UNION DISTINCT` retains its existing global merge behavior; - nullable group expressions are deep-copied and retain nullable semantics. Tests completed locally on latest `main` (`ba8954d543af0bdfb1948a8b89f77f5235ac9259`): - `go test -mod=readonly ./pkg/sql/compile -count=1` - `go test -mod=readonly -race ./pkg/sql/compile -count=1` - `go vet -mod=readonly ./pkg/sql/compile` - latest-main `mo-service` build - 500,257-row standalone regression with parallel scans, nullable set keys, and aggregate checks; expected and actual result: `(859, 858, 429429, 1)` Approved by: @aptend
…#27544) Parallel `INTERSECT` and `MINUS` execute one distinct set operator per worker. Each worker removes duplicates locally, but the worker outputs were merged without a final global distinct phase. As a result, the same set key could be returned once per worker, causing duplicate rows and incorrect downstream aggregates for ordinary `INTERSECT` / `INTERSECT DISTINCT`. This change extracts the existing `UNION DISTINCT` merge-and-group logic into a shared helper and applies it after parallel `INTERSECT` and `MINUS`. `INTERSECT ALL` and the single-worker path retain their existing behavior. The group expressions remain nullable so NULL set keys preserve SQL distinct semantics. Regression tests verify: - parallel `INTERSECT` and `MINUS` add a global distinct merge; - `INTERSECT ALL` keeps its per-worker results without the distinct merge; - `UNION DISTINCT` retains its existing global merge behavior; - nullable group expressions are deep-copied and retain nullable semantics. Tests completed locally on latest `main` (`ba8954d543af0bdfb1948a8b89f77f5235ac9259`): - `go test -mod=readonly ./pkg/sql/compile -count=1` - `go test -mod=readonly -race ./pkg/sql/compile -count=1` - `go vet -mod=readonly ./pkg/sql/compile` - latest-main `mo-service` build - 500,257-row standalone regression with parallel scans, nullable set keys, and aggregate checks; expected and actual result: `(859, 858, 429429, 1)` Approved by: @aptend
…#27544) Parallel `INTERSECT` and `MINUS` execute one distinct set operator per worker. Each worker removes duplicates locally, but the worker outputs were merged without a final global distinct phase. As a result, the same set key could be returned once per worker, causing duplicate rows and incorrect downstream aggregates for ordinary `INTERSECT` / `INTERSECT DISTINCT`. This change extracts the existing `UNION DISTINCT` merge-and-group logic into a shared helper and applies it after parallel `INTERSECT` and `MINUS`. `INTERSECT ALL` and the single-worker path retain their existing behavior. The group expressions remain nullable so NULL set keys preserve SQL distinct semantics. Regression tests verify: - parallel `INTERSECT` and `MINUS` add a global distinct merge; - `INTERSECT ALL` keeps its per-worker results without the distinct merge; - `UNION DISTINCT` retains its existing global merge behavior; - nullable group expressions are deep-copied and retain nullable semantics. Tests completed locally on latest `main` (`ba8954d543af0bdfb1948a8b89f77f5235ac9259`): - `go test -mod=readonly ./pkg/sql/compile -count=1` - `go test -mod=readonly -race ./pkg/sql/compile -count=1` - `go vet -mod=readonly ./pkg/sql/compile` - latest-main `mo-service` build - 500,257-row standalone regression with parallel scans, nullable set keys, and aggregate checks; expected and actual result: `(859, 858, 429429, 1)` Approved by: @aptend
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #27525
What this PR does / why we need it:
Parallel
INTERSECTandMINUSexecute one distinct set operator per worker. Each worker removes duplicates locally, but the worker outputs were merged without a final global distinct phase. As a result, the same set key could be returned once per worker, causing duplicate rows and incorrect downstream aggregates for ordinaryINTERSECT/INTERSECT DISTINCT.This change extracts the existing
UNION DISTINCTmerge-and-group logic into a shared helper and applies it after parallelINTERSECTandMINUS.INTERSECT ALLand the single-worker path retain their existing behavior. The group expressions remain nullable so NULL set keys preserve SQL distinct semantics.Regression tests verify:
INTERSECTandMINUSadd a global distinct merge;INTERSECT ALLkeeps its per-worker results without the distinct merge;UNION DISTINCTretains its existing global merge behavior;Tests completed locally on latest
main(ba8954d543af0bdfb1948a8b89f77f5235ac9259):go test -mod=readonly ./pkg/sql/compile -count=1go test -mod=readonly -race ./pkg/sql/compile -count=1go vet -mod=readonly ./pkg/sql/compilemo-servicebuild(859, 858, 429429, 1)