Repository navigation
fix(sql): lower scalar window inputs and repair NULL and empty reuse - #29918
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? |
6f92286 to
94e21a4
Compare
|
mo-bot review · Commit: Assessment: approve 已完成全部 17 个文件及相关调用者、职责归属、错误与复用路径的审查,无确认的未解决缺陷。窗口输入复用既有标量子查询降级逻辑,执行顺序正确;NULL 比较、边界保留和空输入清理修复保持原有所有权,没有引入重复状态机。 Model: Session: Validation:
Limitations:
|
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 94e21a4c462ca82ad90c52941187f67f99582230
Assessment: approve
已完成全部 17 个文件及相关调用者、职责归属、错误与复用路径的审查,无确认的未解决缺陷。窗口输入复用既有标量子查询降级逻辑,执行顺序正确;NULL 比较、边界保留和空输入清理修复保持原有所有权,没有引入重复状态机。
Model: gpt-6-astra / xhigh
Session: 01a12d8f-7dea-77c2-a565-38d45b5564e4 · slot 0 · generation 0
Validation:
-
确认 HEAD 和 merge-base 精确匹配;两次 attempt 补丁一致,复用上一轮已完成检查。git diff --check 通过,源码工作区保持干净。
-
核对标量列数、行比较/IN/EXISTS 兼容性、聚合/HAVING 后的窗口输入、COUNT 空结果、多个窗口生产者,以及 Prepare→Call→Reset/Free 生命周期。
-
复用冻结的当前 HEAD CI:共享构建、Ubuntu/x86 UT、Linux/arm64 SCA、覆盖率及 PROXY/PESSIMISTIC 两组多 CN BVT 成功;未将 skipped 项计为通过。
-
复用作者报告的七个相关包正常/race 验证、真实 SQL 协议测试、生命周期各 100 次 race 验证,以及 sequence 80/80 两次、窗口输入 22/22 两次和默认帧 10/10 BVT。
-
审查测试的结果与错误断言、失败 SET 保留 session 状态、准备语句空/非空复用、跨批次边界及清理。冻结评论无实质性待解决评审意见。
-
完整变更映射、证据来源和审查记录保存于 attempt-2/review-record.json。
Limitations:
-
冻结材料未包含关联 issue 正文;依据 PR 陈述的行为契约、源码和测试核对。
-
CI 原始日志和作者运行产物未随材料提供;复用了精确 HEAD 的终态快照及详细作者验证记录,本轮未重复执行 native/SQL 测试。
-
没有吞吐基准,不宣称性能提升或已测得无退化;代码审查未发现此次增量引入每行分配、额外 I/O 或新的持续增长状态。
aunjgr
left a comment
There was a problem hiding this comment.
Reviewed 94e21a4 against merge-base 41ac624. No blocking finding.
Window scalar producers are lowered over post-aggregation input before any window operator, retaining the existing scalar correlation/cardinality and COUNT owners. The standalone scalar column-count check does not take over row-comparison or EXISTS consumers. Constant NULL keys preserve previously established peer boundaries, domainless NULL uses nullable comparison/copy without admitting arbitrary ANY values, and cleanup/empty-input reuse no longer retains logical rows or evaluates an empty retained batch.
The tests cover grouped/HAVING and correlated inputs, independent window producers, NULL peers and frames, scalar row/column errors, session state after failed SET, batch boundaries, and prepared nonempty/empty/nonempty reuse. The changed sequence golden explicitly checks rejected invalid assignments rather than accepting generated results.
Validation: reused the reported owning normal/race packages, lifecycle repetitions and real protocol/BVT evidence; current-head CI passes. I did not rerun a native service or multi-CN topology locally.
## What type of PR is this? - [x] Test and CI ## Which issue(s) this PR fixes: Fixes #29925 ## What this PR does / why we need it: Adds regression coverage for LAG/LEAD explicit NULL defaults across partitions of sizes two and one. The cleanup fix already merged in #29918 clears payload-free NULL-vector lengths; these tests verify the reported SQL behavior and protect that reuse contract. SQL tests check untyped NULL, typed DOUBLE NULL, omitted, zero and row-dependent defaults, asserting every value and NULL bit. Vector coverage adds DOUBLE and shrinking, empty and growing lengths, retaining provenance and memory-cleanup assertions. Production code is unchanged. Validation: focused normal and race checks passed 11 top-level tests per mode across vector, window and SQL integration, including all ten new SQL cases and existing cancellation/error/lifecycle controls, with no skips or race reports. Incremental gofmt and go vet passed; configured golangci-lint reported 0 issues. Molint ran over the same three packages; its two unsafe-import diagnostics are in unchanged files verified byte-identical to the base. Tests used Go 1.27.1, CGO_ENABLED=1 and fresh native artifacts. Local SQL fixtures used a diagnostic configuration overlay changing only the Unix socket pathname to avoid Linux path-length limits; TCP query execution and assertions were unchanged. The final gpt-6.1-sol/xhigh review accepted the exact committed candidate. Remote CI remains pending. Closes #29925 <!-- mo-bot-work:v1 d588c0dab2bbd7a86c7e440568816522c76cb3533c546f4709cf5879e68851ca --> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #29877
Fixes #29878
Fixes #29917
What this PR does / why we need it:
Window inputs such as
ROW_NUMBER() OVER (PARTITION BY id ORDER BY (SELECT NULL))were accepted by binding but reached execution without scalar-subquery lowering. Literal NULL peer keys also failed, and restored NULL execution exposed payload-free vector cleanup and empty-input reuse defects.Design and behavior
Compatibility: invalid
SET @v=(SELECT a,b ...)now fails on column count instead of silently taking the first column or reaching a row-count error. An independently executed MySQL 8.0.46 control rejects this query for zero, one and multiple rows too. The existing sequence BVT now explicitly checks rejection and preservation of the previously assigned variable value; valid single-column assignments remain covered. Row comparisons and EXISTS still accept multiple columns. There are no persisted-format, catalog or wire-layout changes.Validation
Rebased onto
mainat41ac6242b7620aa069db91492db1d41584319b05without conflicts. Final code was checked with Go 1.27.1 and fresh, matching CPU native artifacts.-race -count=1UT:pkg/compare,pkg/container/vector,pkg/partition,pkg/sort,pkg/sql/plan,pkg/sql/colexec/window, andpkg/sql/colexec/partition.TestWindowScalarSubqueryInputs(5.543s / 9.359s). Covers scalar/window keys, correlation, grouped/HAVING input, empty/multiple rows and columns, NULL peers, stacked windows, ROWS/RANGE, prepared nonempty → empty → nonempty reuse, batch boundaries, and failed SET preserving session state.sequence/seq_func2.sql80/80 twice, window scalar inputs 22/22 twice, and existing default-frame controls 10/10. No failed, ignored or abnormal statements. Independent teardown checks found no leftover test tables, sequences or window database.sort_spill_mem=1controls with NULL order/partition keys also return the expected results.go vet, repository molint, and configured golangci-lint 2.14.0. 0 introduced findings; golangci 0 issues. Eight molint diagnostics are identical with the complete PR Go delta replaced by exact base sources; they are not new findings.gpt-6.1-solwithxhigh; no unresolved material blocker.The latest CI correction changes tests and their expectations only; it adds no production work, allocation or special execution path. The overall change adds no worker, cache, state machine or per-row allocation. This is a functional correction; no query-throughput improvement is claimed.
Production: 74 insertions / 6 deletions; tests/SQL/results: 523 insertions / 18 deletions; documentation: 0. Fixtures and common owners are reused. These checks do not claim a full local multi-CN Compose run or a passing remote CI run; remote CI remains to be evaluated.