Skip to content

[4.2.1 hotfix] fix(plan): align VALUES column common types - #29218

Merged
aptend merged 4 commits into
matrixorigin:hotfix-20260922from
aptend:fix/v4.2.1-hotfix-20260916-values
Sep 22, 2026
Merged

aptend merged 4 commits into
matrixorigin:hotfix-20260922from
aptend:fix/v4.2.1-hotfix-20260916-values

Conversation

@aptend

@aptend aptend commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • 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 9572bd3311abb16d1df939956408a727bcf83eba ./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.

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.

Approved by: @XuPeng-SH

(cherry picked from commit 161fe8e)
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify mergify Bot added the kind/bug Something isn't working label Sep 22, 2026
Match main while the local Iceberg E2E suite is stabilized; the Docker Hub minio/mc image used by this workflow is currently inaccessible.

(cherry picked from commit 70b8d18)
@aptend
aptend requested a review from fengttt as a code owner September 22, 2026 05:08

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT-6 Astra medium deep review at exact head 37b9c8c: REQUEST_CHANGES. [P1] In pkg/sql/plan/query_builder.go around lines 7920-7931, mixed CHAR/VARCHAR VALUES rows use castTypes[0] as the complete common type; width aggregation runs only in the no-cast branch. VALUES row order can therefore select VARCHAR(1) and truncate an 8-character later row, while reversing the rows preserves it. Compute a sufficient order-independent width across every input and test both orders through execution. [P2] The same common-type path can narrow VECF64 to VECF32, losing precision and retaining row-dependent vector dimensions; define and test an order-independent vector type/dimension policy. [P2] signed BIGINT is selected for a negative plus UINT64_MAX input even though the values require a common DECIMAL domain, causing out-of-range execution. Add the signed/unsigned common-domain handling. Exact-head focused tests passed, but normal-comparison VALUES BVT, same-instance rerun, and attributable service-build evidence are also missing.

@aptend
aptend requested a review from XuPeng-SH September 22, 2026 06:13
@mergify mergify Bot added the kind/test-ci label Sep 22, 2026

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT-6 Astra medium re-review at exact head 0798c37: REQUEST_CHANGES. [P2] A string row can bypass vector precision and dimension protection: a VALUES column mixing VECF32/VECF64 with a string can select VECF32 and round 16777217, or accept inconsistent dimensions depending on row order. Resolve the complete column domain before choosing casts or rejecting dimensions, and add three-row permutation coverage. [P2] Unconditional COALESCE resolution rejects previously valid homogeneous GEOMETRY VALUES such as row(st_point(1,2)); preserve supported homogeneous domains without requiring a COALESCE overload and cover geometry with and without NULL. [P2] Exact-head service-build and normal-comparison BVT evidence remains unattributable because the PR metadata has empty head/command/case fields and embedded build commit 3e8f416. Supply actual exact-head build identity and named same-instance comparison reports with readiness and terminal status. Prior CHAR/VARCHAR, two-type vector, and signed/unsigned blockers appear resolved.

@aptend
aptend requested a review from XuPeng-SH September 22, 2026 06:45

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT-6 Astra medium re-review at exact head 263e5b1: REQUEST_CHANGES. Prior correctness blockers are closed: mixed vector/string ordering and precision, vector dimensions, homogeneous GEOMETRY with and without NULL, CHAR/VARCHAR width, and signed/unsigned common domain all pass the rechecked cases. [P2] Exact-head service/BVT evidence is not fully verifiable: attach inspectable build output, named mo-tester comparison reports with runner exit statuses, and mo-service.log showing ISCP-Task Start readiness for the reported 26/26 same-instance runs. SQL readiness and clean shutdown alone do not establish the required BVT evidence.

@aptend

aptend commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

Exact-head validation artifacts for 263e5b16be92602921218ce799c9c9a671d0d98d are attached here:

https://gist.github.com/aptend/bfa6b3b0e90eca49abbef46c04f5913f

The gist contains the exact-head build output, package-test/vet/lint terminal logs, checksums, full mo-service.log, readiness record, and both named mo-tester reports. SQL became ready after 2s; ISCP-Task Start was observed after 15s before either retained comparison run. values.sql then passed 26/26 twice on the same instance with runner exit 0, followed by Shutdown complete and service exit 0. The PR head was not changed after collecting this evidence.

@aptend
aptend requested a review from XuPeng-SH September 22, 2026 07:07

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT-6 Astra medium force re-review: APPROVE. Reviewed all five changed files at exact head 263e5b1 against base 9572bd3. Mixed vector/string order independence, precision and dimension rejection, homogeneous GEOMETRY with NULL, CHAR/VARCHAR width, signed/unsigned DECIMAL domain, DECIMAL scale and NULL handling are closed. Inspected exact-head build/package/vet/lint and validation artifacts: values.sql passed 26/26 twice on the same instance with runner exit 0, ISCP readiness precedes runs, service logs show expected errors and clean shutdown, and manifest checksums match. No blocking finding remains.

@aptend
aptend merged commit fe0f106 into matrixorigin:hotfix-20260922 Sep 22, 2026
5 checks passed
aptend added a commit that referenced this pull request Sep 22, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue #27933

## What this PR does / why we need it:

Backport the ODKU irregular-index routing from #27956, the synchronous
FULLTEXT optimization from #28066, and the generated-key safety guard
from #28076 to `hotfix-20260922`. This PR is independent of the VALUES
fix in #29218.

For `INSERT ... ON DUPLICATE KEY UPDATE` on tables with classic
synchronous FULLTEXT indexes:

- unchanged conflict rows skip hidden FULLTEXT delete, tokenization, and
insert work;
- new rows and rows whose indexed values change continue through the
existing maintenance path;
- all physical definitions of one logical irregular index stay in the
same routing group;
- comparisons include row identity and supported indexed text columns
and use null-safe equality;
- unsupported types, unknown plugins, asynchronous indexes, and
incomplete metadata conservatively retain the original maintenance path.

The backport also expands explicit assignments and implicit `ON UPDATE`
columns through generated-column dependencies before primary/unique-key
and irregular-index classification. An ODKU that can change a generated
primary or unique key is rejected before maintenance can use a stale
document identity; unrelated assignments remain supported.

Hotfix-specific adaptation:

- this release line has no newer `INSERT ALL` planner path, so no
corresponding change is included;
- this release line predates ordered ODKU assignments, so dependency
closure is computed from the hotfix planner's final explicit and
implicit assignment set.

Regression coverage includes real planner-entry tests for explicit and
implicit generated-UNIQUE dependencies, an unrelated-update control,
sink-consumer plan invariants, and distributed generated-column/ODKU
cases. Existing FULLTEXT and vector-index maintenance coverage is
retained.

The PR also carries main's temporary local Iceberg E2E disable while the
workflow's Docker Hub dependency is unavailable.

### Validation

Validated exact head `38cb71fcc3add986f99786fa9b29f5c90d159181`:

- `make build`: PASS; `./mo-service -version` reports branch
`backport/28066-on-9572bd3`, commit `38cb71fcc3`.
- `GOWORK=off go test -count=1 -timeout=10m ./pkg/sql/plan
./pkg/fulltext/plugin/plan`: PASS (`4.552s`, `0.043s`).
- `GOWORK=off go vet ./pkg/sql/plan ./pkg/fulltext/plugin/plan
./pkg/indexplugin/plan`: PASS.
- `golangci-lint run -c .golangci.yml --new-from-rev
9572bd3 ./pkg/sql/plan
./pkg/fulltext/plugin/plan ./pkg/indexplugin/plan`: PASS (`0 issues`).
- Fresh launch reached SQL readiness on `127.0.0.1:6001` after 11
seconds; `select version(), 1` returned `8.0.30-MatrixOne-v2806695723,
1`.
- Same-instance normal comparison, run twice with `./run.sh -n -g -t 2`:
`generated_column.sql` passed `174/174` in both runs;
`on_duplicate_key_modern.sql` passed `265/265` in both runs. Each
combined run was `439/439`, 100%, with 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`.

---------

Co-authored-by: 和光同尘 <[email protected]>
@aptend aptend mentioned this pull request Sep 22, 2026
1 of 7 tasks
XuPeng-SH pushed a commit that referenced this pull request Nov 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to #29214 and #27933.

## What this PR does / why we need it:

Backport #29218 and #29219 from the independent `4.2-hotfix-20260922`
line to `v4.2.1-hotfix`. Both cherry-picks apply without conflicts;
their 20 delivered files are identical to the source hotfix. Omit the
unrelated temporary Iceberg CI disable carried by #29218.

- Resolve one common type across an entire VALUES column, preserving
DECIMAL precision/scale, NULLs, character widths and VECF64 precision;
reject mismatched vector dimensions independently of row order.
- Skip synchronous irregular-index maintenance for ODKU conflicts whose
indexed columns cannot change. Classic FULLTEXT also skips rebuilds when
the final stored text is equal. New rows, changed indexed values,
unsupported proof types and plugins retain maintenance; generated-key
dependency guards and IVF INCLUDE payload updates are preserved.

No catalog, index-storage or protocol migration is introduced. These
optimizations do not claim to fix the cost of changed-text posting
deletion or ordinary INSERT workloads.

Validation (Linux/amd64, Go 1.26.4, CGO):

- `make thirdparties`, `make cgo`, release `make build
GOBUILD_OPT=-p=4`: PASS.
- Focused regression selection and full normal suites for `pkg/sql/plan`
and `pkg/fulltext/plugin/plan`: PASS. `pkg/indexplugin/plan` compiles
successfully and has no test files.
- Official mo-tester comparison, twice on the same isolated service:
VALUES 26/26, ODKU 265/265, generated columns 174/174 and IVF INCLUDE
DML 55/55; **520/520 per run**, no failed/ignored/abnormal statements.
- Local SCA covers all 141 changed/reverse-dependent packages, including
tests: `go vet -mod=readonly -p=4 <closure>` PASS; repository-pinned
golangci-lint 2.6.2 `run --new-from-rev=origin/main <closure>` and the
same check against `4711b18e82` PASS (`0 issues`). `molint check
-mod=readonly -p=4 <closure>` has no new findings: its two unchanged
unsafe-recover diagnostics reproduce identically on clean base
`4711b18e82` with the same binary and package closure.
- `gofmt` and `git diff --check`: PASS.

---------

Co-authored-by: 和光同尘 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/test-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants