Repository navigation
feat(sql): support EXCEPT ALL multiset subtraction - #29228
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Local exact-head fallback review (Astra thread capacity unavailable), substantive result REQUEST_CHANGES. Reviewed head 194d1f4 against base 3727c5c. Source audit found no confirmed semantic or cleanup defect in duplicate/NULL subtraction, mpool Reset/Free, single-owner consolidation, or remote shape restoration. However, this PR changes distributed and remote execution paths while explicitly lacking local live one-CN/two-CN BVT execution. Before merge, attach exact-head remote/two-CN normal-comparison evidence with teardown, covering nested remote MINUS ALL, duplicate/NULL cardinality, malformed instruction rejection, operator reset/reuse, and mpool balance. The existing unit and codec tests are not sufficient evidence for the distributed contract.
XuPeng-SH
left a comment
There was a problem hiding this comment.
GPT-6 high force review at exact head 2955326 (base 1634996): substantive REQUEST_CHANGES. Formal review is COMMENT because this PR is self-authored.
[P2] Predicate pushdown can break PAD SPACE multiset subtraction. The new MINUS_ALL physical key treats 'a ' and 'a' as the same subtraction key, but the existing pushdown path in pkg/sql/plan/pushdown.go:879 pushes an outer predicate into both inputs without checking that it preserves the equivalence class. Reproduced on the reviewed head with left VARCHAR(8) containing two 'a ' rows and right CHAR(8) containing one 'a': EXCEPT ALL returns 1 row, but adding outer WHERE HEX(v)='6120' returns 2 rows instead of 1 because the right 'a' is filtered before subtraction. A LIMIT control blocks pushdown and returns 1. Restrict non-equivalence-preserving pushdown and add this public SQL regression.
[P2] Design approval is still not recorded. docs/rfcs/00000000_except_all.md still says maintainer design approval is pending, while this adds public SQL semantics, a new operator, remote tree restoration, and a single-owner/in-memory capacity model.
[P2] set_operator.test has one successful 31/31 run but no same-instance rerun and independent post-teardown checks; its DROP TABLE IF EXISTS setup can hide residue. Add the required repeat and explicit cleanup verification.
The implementation review otherwise closed NULL/count/batch/parallel/remote-shape/prepared/reset-cleanup concerns. Current CI is green, including two-CN integration and 118/118 JSON BVT, but those tests did not catch the PAD SPACE pushdown counterexample. Coverage was not used as a criterion.
|
Addressed the latest review at
Production build, final vet, incremental lint (0 issues), gofmt and diff checks pass. GPT-6 medium design and separate overall review found no material blocker in this correction. New-head CI remains pending; no merge performed. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Force review(GPT-6 high,head df3908e5f856e54260b000432625c1b63d3ac8d3)
结论:当前未确认新的实现缺陷;此前发现的 PAD SPACE predicate-pushdown 计数问题已修复并独立验证。planner/operator/transport focused tests、真实 1CN/2CN 集成、同实例 equality/prepared reuse 均通过。
仍有两个验收门槛未闭合:
- RFC
docs/rfcs/00000000_except_all.md仍标记为maintainer design approval pending。该功能新增公共 SQL、算子及远端执行契约,需维护者确认 owner、内存计数和混合版本限制。 - 当前 exact-head 的 UT、SCA、proxy BVT、两 CN pessimistic BVT 当时仍在运行,需取得终态成功证据。
因此本次是 substantive REQUEST_CHANGES 结论,但由于这是作者本人 PR,按规则以 COMMENT 提交。
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #28234
What this PR does / why we need it:
Implement
EXCEPT ALL/MINUS ALLas multiset subtraction: each key, including NULL, is emittedmax(left_count - right_count, 0)times. The dedicated MinusAll operator builds mpool-accounted right-side multiplicities, consumes them while probing, and returns surviving original left rows.Parallel input work is preserved, but both complete streams feed one subtraction owner; the existing broadcast set-operation path must not multiply results. Planner support includes INSERT SELECT, physical PAD SPACE equality keys and prepared-plan key refresh. The new VM opcode is appended without renumbering existing opcodes.
Remote decoding restores the compiler-generated two-merge input shape for all binary set operators: Minus, MinusAll, Intersect, and IntersectAll. Restoring only MinusAll was insufficient: an actual two-CN execution of
(L EXCEPT ALL R) INTERSECT ALL Lwith the owner placed away from ingress panicked because the ancestor had only one decoded child. The shared restoration fixes this boundary without changing the wire format or placement policy; malformed shapes are rejected before mutating the tree.Validation
PAD SPACE-aware set operations retain outer predicates above the set boundary: filtering byte-distinct but key-equivalent rows before subtraction produces wrong multiplicities. This also protects normalized UNION/INTERSECT/MINUS; branch-local filters, exact-key operations and UNION ALL retain existing optimization. See design revision 2; maintainer design approval remains pending.
Latest follow-up validation:
'a 'rows minus one CHAR'a', filtered byHEX(v)='6120', returned 2 instead of 1, twice on the same instance; a LIMIT control returned 1. After the fix, HEX/LENGTH predicates and LIMIT/no-LIMIT controls pass on private 1CN/2CN clusters (43.917s), including EXCEPT ALL, its MINUS ALL alias, distinct EXCEPT, INTERSECT, INTERSECT ALL and UNION ALL.pkg/sql/plansuite 5.400s PASS, including a six-operator × keyed/unkeyed boundary matrix, branch-local pushdown and LIMIT residual preservation.set_operator.testnormal mo-tester comparison twice on the same private CN: 33/33 each, zero failed/ignored/abnormal, including two new explicit teardown statements. Independent schema/table/account inventories before and after each pass match; cluster Close and subsequent listener refusal pass (11.669s). This is direct embedded-CN evidence, not proxy CI.Earlier feature validation (historical where not exercised above):
pkg/sql/compiletests, including complete remote scope encode/decode with nested PreScopes, all four binary ancestors, key expressions, receiver ranges, connector identity, and malformed nested wire fixtures.pkg/sql/colexec/minusalltests, including injected build/probe failures, Reset/reuse and zero mpool balance after teardown.The initial implementation also passed planner/VM package tests and MinusAll race tests; these are historical checks, not a claim that the full CI matrix was rerun locally after the follow-up.
Limits