Repository navigation
fix(plan): align VALUES column common types - #29215
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? |
b032646 to
6ac0bac
Compare
|
Fixed and rebased onto main (1a24bdb), pushed as 6ac0bac. Changes: preserve DATETIME fractional precision by retaining the resolved maximum FSP; preserve the common CHAR type/width for pure CHAR VALUES columns; add planner and execution-level regressions for both row orders, plus parameter/vector/error coverage. Validation: go test ./pkg/sql/plan -coverprofile=/tmp/matrixone-pr29215-plan.cover -count=1 (81.8% package coverage; helper 92.1%), go vet ./pkg/sql/plan, make build, and mo-tester normal comparison 16/16 passed (100%). New GitHub CI has started. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review (gpt-6-astra medium, exact head 6ac0bac).\n\nREQUEST_CHANGES.\n\nP2 — VALUES common typing drops PAD SPACE semantics. At pkg/sql/plan/query_builder.go:10214, rebuilding the common column plan.Type preserves physical type fields but loses PadSpace. A CHAR-derived VARCHAR expression retains that provenance, while the VALUE_SCAN column loses it; downstream comparison binding then omits the padding-normalization cast.\n\nCounterexample:\nSELECT x = 'a'\nFROM (\n VALUES ROW(\n COALESCE(CAST('a ' AS CHAR(4)), CAST('x' AS VARCHAR(8)))\n )\n) v(x);\n\nAn exact-head parsed-SQL planner/expression-executor probe showed the base column with PadSpace=true returns true, while this head has PadSpace=false and returns false, despite identical materialized bytes ("a "). Preserve CHAR-derived comparison provenance when constructing the common column type, and add comparison/DISTINCT regression coverage.\n\nAll other inspected closures—DECIMAL widening/scale and row-order independence, typed NULL/all-NULL, vector promotion/rejection, DATETIME/CHAR, casts, constant materialization, and prepared-plan replacement—had no additional concrete blocker. The existing planner/build evidence and 16/16 BVT were reviewed, but they do not cover this provenance boundary.
|
Addressed the PAD SPACE finding in 2c80781. VALUES now retains CHAR-derived comparison provenance when constructing its common VARCHAR/TEXT column type, independently of row order, while preserving materialized bytes and ordinary VARCHAR semantics. Verified the original SQL against the previous head: comparison returned 0 and DISTINCT produced 2 groups. With the fix, comparison returns 1 and DISTINCT produces 1 group; HEX(x) remains 61202020. Added mixed-order, NULL, VARCHAR-only and CONCAT controls. Validation: focused and full planner tests, vet, incremental lint (0 issues), build, and normal VALUES BVT comparison (22/22, including same-instance repeat) passed. GPT-6 medium design and final review completed with no remaining blockers. Remote CI remains pending. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep re-review (gpt-6-astra medium, exact head 2c80781).\n\nAPPROVE.\n\nThe prior P2 PadSpace provenance blocker is fixed. Exact-head execution retains the CHAR-derived PadSpace metadata, the comparison returns true, and the materialized bytes remain unchanged. The complete four-file diff and affected VALUES consumers were re-read.\n\nFocused tests and probes cover DECIMAL precision/scale widening through Decimal256, row-order independence, NULL/all-NULL, vectors, casts, constant folding/materialization, and prepared parameter replacement. Public VALUES BVT evidence is 22/22 twice, including DISTINCT and row-order/NULL/VARCHAR controls.\n\nRemote CI was still in progress at review time, so this is not a CI-green claim; the force review decision is based on the exact-head source review and available focused/public evidence. No concrete correctness or validation blocker remains.
Merge Queue Status
This pull request spent 12 seconds in the queue, including 1 second running CI. Required conditions to merge
|
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue #29214 ## What this PR does / why we need it: Backport #29215 to `hotfix-20260922`. The VALUES planner previously derived types row by row while materializing `VALUE_SCAN`. That made the result depend on row order and could truncate values, lose precision, or select a type that could not represent every row. This PR resolves one order-independent common type for each VALUES column before materialization: - preserves DECIMAL precision and scale across all rows; - types bare `NULL` values consistently, including all-NULL columns; - uses the maximum declared width for mixed `CHAR`/`VARCHAR` values; - preserves `VECF64` when mixed with `VECF32` and string literals, independently of row order; - rejects inconsistent vector dimensions across the complete column domain; - preserves already-homogeneous domains such as `GEOMETRY`, including columns containing `NULL`; - uses a DECIMAL domain when mixed signed/unsigned integers cannot fit one integer type. The change is scoped to VALUES planning and does not alter global expression coercion such as `COALESCE`. It is adapted to the v4.2.1 type model without bringing newer main-only PAD SPACE protobuf and cast-overload dependencies into the hotfix branch. Regression coverage includes planner unit tests and distributed VALUES cases for reversed row order, mixed widths and numeric domains, NULL placement, all-NULL columns, DECIMAL scale, vector permutations/dimensions, and homogeneous GEOMETRY. The PR also carries main's temporary local Iceberg E2E disable while the workflow's Docker Hub dependency is unavailable. ### Validation Validated exact head `263e5b16be92602921218ce799c9c9a671d0d98d`: - `make build`: PASS; `./mo-service -version` reports branch `fix/v4.2.1-hotfix-20260916-values`, commit `263e5b16be`. - `GOWORK=off go test -count=1 -timeout=10m ./pkg/sql/plan`: PASS (`4.473s`). - `GOWORK=off go vet ./pkg/sql/plan`: PASS. - `golangci-lint run -c .golangci.yml --new-from-rev 9572bd3 ./pkg/sql/plan`: PASS (`0 issues`). - Fresh launch reached SQL readiness on `127.0.0.1:6001` after 5 seconds; `select version(), 1` returned `8.0.30-MatrixOne-v4.2.120260916, 1`. - Same-instance normal comparison: `./run.sh -n -g -t 2 -p test/distributed/cases/dml/select/values.sql -s test/distributed/resources`; run 1: `26/26`, run 2: `26/26`, both 100%, no failed/ignored/abnormal cases. - The service terminated cleanly after the rerun (`Shutdown complete`, exit 0). Full MatrixOne PR CI/BVT is not scheduled by the current workflow because its branch filter does not include base branch `hotfix-20260922`.
What type of PR is this?
Which issue(s) this PR fixes:
issue #29214
What this PR does / why we need it:
Resolve one common type for each VALUES column before materializing VALUE_SCAN. This prevents row-order-dependent DECIMAL precision/scale corruption, types bare NULL values consistently, and preserves vector-typed VALUES.
Adds planner coverage and distributed SQL regression cases for mixed DECIMAL scales, reversed row order, NULL placement, all-NULL columns, and vector values.