Repository navigation
Conversation
Backport the scalar row-count fix from matrixorigin#27436. Adapt coverage to the 4.2 expression and prepared projection fixtures. (cherry picked from commit 087092c)
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. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 628946aca6ff3f3a3219046c17b41eab47d88d90
Assessment: request_changes
The change fixes the reproduced ordered-insert failure by reusing the existing scalar executors, but their new logical cardinality breaks an existing metadata_scan APPLY query. The consumer must be updated to handle constant vectors with batch-sized logical lengths.
Model: gpt-6.1-terra / max
Session: 01a227fa-9be9-7372-8896-a8b81f9696c9 · slot 0 · generation 43
- P2
pkg/sql/colexec/evalExpression.go:578: A CROSS APPLY evaluates metadata_scan(@src, @col) against a left input batch containing more than one row.
Impact: The variable vectors now have the left batch's logical length, but metadata_scan rejects arguments whose length is not exactly one. A query that previously succeeded therefore returns Error 20101: internal error: wrong input len.
Evidence: ApplyArgsEval evaluates arguments against the whole input batch at pkg/sql/colexec/table_function/table_function.go:255, and handleDataSource enforces length one at pkg/sql/colexec/table_function/metadata_scan.go:162. An embedded SQL probe reproduced the failure for a two-row left input; the same probe passed with the base evalExpression.go overlaid. Preserve the batch-sized cardinality needed by sorting while making metadata_scan accept constant vectors with multiple logical rows, and add an APPLY regression test.
Validation:
-
Paths below are relative to /mnt/nvme/mo-bot-55-live/state/jobs/3621da51ec94d3f0ef94c545.
-
Isolation preflight passed: model-switch-1795970579502307811/preflight.log and checks/1795970622276942627-2.json in that directory.
-
Focused colexec and hashbuild tests passed: model-switch-1795970579502307811/focused-tests.log and checks/1795970720050536361-2.json.
-
The ordered-insert SQL probe returned the expected two rows after each of two executions on the candidate; the base-executor overlay reproduced the shuffle index error. See model-switch-1795970579502307811/original-candidate.log and original-baseline.log, with receipts checks/1795970817587124429-2.json and checks/1795970936782447508-2.json.
-
The metadata_scan probe failed on the candidate for the two-row APPLY and passed with the base executor overlaid. See attempt-1/candidate-apply-retry.log and checks/1795970562603124623-2.json, and model-switch-1795970579502307811/baseline-apply.log and checks/1795970679733910487-2.json.
Limitations:
-
The SQL probes used an embedded cluster. The metadata_scan target had no flushed metadata objects, so that probe establishes success versus error rather than returned metadata contents.
-
The author's reported BVT and race results were not accompanied by local validation logs; the frozen CI snapshot had UT and BVT jobs pending.
-
The updated review plan and discussion assessment are retained in model-switch-1795970579502307811; attempt-1 was read-only in this session.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 85f0688d17dfcefd468b3305eb33dab1c88bc80d
Assessment: approve
The scalar executors now give constant parameter and variable vectors the input batch's logical cardinality while retaining one physical value. This reuses the existing vector and expression owners, and the variable overwrite avoids allocating for the previous batch size. The prior review's metadata_scan APPLY regression is resolved: the consumer accepts broadcast constants and retains its rejection of flat multirow arguments. The reproduced ordered insert and the affected APPLY paths both passed through the MySQL frontend; no actionable defect remains.
Model: gpt-6.1-terra / max
Session: 01a226fb-40e1-7c82-8448-1a1fd4af5968 · slot 1 · generation 36
Validation:
-
Isolation preflight and git diff --check passed (preflight.log, diff-check.log; checks/1795973541945615583-3.json and checks/1795973874275558202-3.json). Native prerequisites were copied from a repository Makefile build after verifying identical Makefile, cgo, and thirdparties tree IDs; native-provenance.txt records the comparison.
-
Focused parameter, variable, hash-build, and metadata_scan tests passed under the race detector with nonempty named selections (focused-race.log; checks/1795973821019382052-3.json). The colexec, hashbuild, and table_function packages also passed with -short (packages.log; checks/1795973897764239182-3.json).
-
An embedded-cluster MySQL frontend probe ran the ordered prepared insert twice and observed rows 1/created and 2/created after each execution. It also verified two-row metadata_scan APPLY with variables and mixed literal arguments against flushed metadata, and flat multirow rejection (sql-probe.log; checks/1795973919278449305-3.json).
-
A separate embedded MySQL probe exercised binary prepared metadata_scan APPLY twice, NULL rejection, and a successful execution after NULL (sql-prepared-probe.log; checks/1795974017845420782-3.json).
-
The previous review's base-expression overlay produced the reported index-out-of-range failure for the ordered insert, while its prior candidate passed. Its baseline expression blob matches this assignment's base; the changes since that reviewed head affect only metadata_scan. The earlier receipt and logs are identified in evidence.json:discussion_index.
Limitations:
-
The exact mo-tester case and result-file comparison were not independently run: the runner was not installed and the attempt to fetch it timed out (mo-tester-fetch.log; checks/1795974166655166506-3.json). The PR reports 35/35 statements passing twice, but its underlying run logs were not supplied. The newly added ordered-insert behavior was independently checked through the embedded MySQL frontend.
-
There is no maintained SQL case specifically for metadata_scan APPLY; its producer and consumer have focused unit coverage, and the independent embedded SQL probes exercised the integrated path.
What type of PR is this?
Which issue(s) this PR fixes:
#33452
Related to #27415. Backport of #27436 to
4.2-dev.What this PR does / why we need it:
A prepared scalar in the projection of a multi-row ordered insert has logical length one on 4.2.9. The sorter copies the projection into a flat batch that claims more rows than the copied scalar column, then returns SQL error 20101 when it permutes the rows. This blocks a tenant event backfill during upgrade.
Use the input batch row count as the logical length of constant parameter and variable results, including cached values, NULL, and fully masked input. Scalar storage stays constant-size. The 4.2 variable executor clears the previous logical length before overwriting its cached scalar so allocation is based on a single stored value, even when the previous batch was large.
Validation
APPLY regression follow-up on
85f0688dmetadata_scannow accepts nonempty scalar constants broadcast over an APPLY input batch while retaining rejection of flat multirow arguments. NULL and non-string inputs return an error before reading vector storage.go test -race -count=1 ./pkg/sql/colexec/table_function, scopedgo vet, and incremental golangci-lint pass (0 new issues). Existing MOI prepared-insert TCP/BVT evidence remains valid.85f0688dapproved with no actionable findings.