Skip to content

fix(frontend): use hidden fake pk type for data branch lca probe - #26795

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-26072-7dc11f00
Aug 8, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-26072-7dc11f00

Conversation

@gouhongshen

@gouhongshen gouhongshen commented Aug 8, 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:

Fixes #26072

What this PR does / why we need it:

Root cause

For tables without an explicit primary key, hash-diff matching uses the visible columns as the fake-PK identity, but the LCA SQL probe joins through the generated hidden __mo_fake_pk_col. The probe selected its cast/equality type from the first visible column instead of the hidden key column. When the first visible column was DOUBLE, the generated join became serial(__mo_fake_pk_col) = serial(cast(... AS DOUBLE)), so existing LCA rows were treated as misses. DATA BRANCH DIFF consequently omitted no-PK deletes and updates, and MERGE left stale rows beside updated rows.

Changes

  • Use the hidden fake-PK column's type for fake-PK LCA probe casts and equality predicates; real and composite primary-key paths are unchanged.
  • Add a frontend unit regression that captures the generated probe SQL for a no-PK table whose first visible column is DOUBLE and requires the hidden BIGINT UNSIGNED key type.
  • Extend the existing special-float BVT to assert no-PK DIFF emits the NaN DELETE and +Inf UPDATE, preserves the unchanged -Inf row, and that MERGE removes/replaces the corresponding destination rows. The same case continues to cover all three special values through primary-key OUTPUT AS, MERGE, PICK, and portable SQL behavior.

Issue-to-test proof

  • pkg/frontend/data_branch_hashdiff_test.go: directly proves the corrected LCA join SQL for the failing no-PK schema shape.
  • test/distributed/cases/git4data/branch/edge/branch_float_special_values.sql: proves the no-PK NaN deletion, +Inf update, -Inf preservation, and final MERGE state, in addition to the original primary-key cases for all three special values.

Tests run

  • make build
  • .agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=120s -run '^TestHandleDelsOnLCA_SQLPaths/fake_pk_sql_builder_uses_the_hidden_key_type$' ./pkg/frontend
  • .agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=180s -run '^(TestHandleDelsOnLCA_SQLPaths|TestHashDiff_)' ./pkg/frontend
  • .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/frontend
  • GOWORK=off go vet -mod=readonly ./pkg/frontend with the repository CGo include/library paths
  • branch_float_special_values.sql through mo-tester: 257/257 passed with -n -r 100
  • merge_8.sql through mo-tester: 172/172 passed with -n -r 100

The BVT runs use -n because current result metadata contains unrelated version-dependent width differences; all SQL result values and ordering were compared.

Residual risks

No API or schema behavior changes are introduced. The fix adds no fallback path, query, or concurrency/resource-lifecycle change. The existing BVT metadata drift remains outside this focused fix and is explicitly isolated by -n during verification.

@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 →

@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.

Reviewed base 629cbbe2fe51d6d457a31f450c7e5c1bc4628213 at head a149e46225687affb649a311812f64828d03fb29.

No material issue found. The coordinator review and an independent GPT-5.6 Sol medium review both verified fake-PK construction, SQL and reader fallback consistency, uint64 key typing, schema evolution, and NaN/Inf behavior.

git diff --check passed. Exact-head CI passed Ubuntu UT, arm64 SCA, coverage, pessimistic BVT, proxy BVT, Iceberg, MongoDB, and connector checks; optional Darwin/Upgrade jobs were skipped. Local exact-head tests were not run because the shared worktree is on an unrelated commit.

@XuPeng-SH
XuPeng-SH merged commit 54c6c9b into matrixorigin:main Aug 8, 2026
26 checks passed
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…rixorigin#26795)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

Fixes matrixorigin#26072

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

### Root cause

For tables without an explicit primary key, hash-diff matching uses the
visible columns as the fake-PK identity, but the LCA SQL probe joins
through the generated hidden `__mo_fake_pk_col`. The probe selected its
cast/equality type from the first visible column instead of the hidden
key column. When the first visible column was `DOUBLE`, the generated
join became `serial(__mo_fake_pk_col) = serial(cast(... AS DOUBLE))`, so
existing LCA rows were treated as misses. `DATA BRANCH DIFF`
consequently omitted no-PK deletes and updates, and MERGE left stale
rows beside updated rows.

### Changes

- Use the hidden fake-PK column's type for fake-PK LCA probe casts and
equality predicates; real and composite primary-key paths are unchanged.
- Add a frontend unit regression that captures the generated probe SQL
for a no-PK table whose first visible column is `DOUBLE` and requires
the hidden `BIGINT UNSIGNED` key type.
- Extend the existing special-float BVT to assert no-PK DIFF emits the
NaN DELETE and `+Inf` UPDATE, preserves the unchanged `-Inf` row, and
that MERGE removes/replaces the corresponding destination rows. The same
case continues to cover all three special values through primary-key
`OUTPUT AS`, MERGE, PICK, and portable SQL behavior.

### Issue-to-test proof

- `pkg/frontend/data_branch_hashdiff_test.go`: directly proves the
corrected LCA join SQL for the failing no-PK schema shape.
-
`test/distributed/cases/git4data/branch/edge/branch_float_special_values.sql`:
proves the no-PK NaN deletion, `+Inf` update, `-Inf` preservation, and
final MERGE state, in addition to the original primary-key cases for all
three special values.

### Tests run

- `make build`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=120s
-run
'^TestHandleDelsOnLCA_SQLPaths/fake_pk_sql_builder_uses_the_hidden_key_type$'
./pkg/frontend`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=180s
-run '^(TestHandleDelsOnLCA_SQLPaths|TestHashDiff_)' ./pkg/frontend`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s
./pkg/frontend`
- `GOWORK=off go vet -mod=readonly ./pkg/frontend` with the repository
CGo include/library paths
- `branch_float_special_values.sql` through mo-tester: 257/257 passed
with `-n -r 100`
- `merge_8.sql` through mo-tester: 172/172 passed with `-n -r 100`

The BVT runs use `-n` because current result metadata contains unrelated
version-dependent width differences; all SQL result values and ordering
were compared.

### Residual risks

No API or schema behavior changes are introduced. The fix adds no
fallback path, query, or concurrency/resource-lifecycle change. The
existing BVT metadata drift remains outside this focused fix and is
explicitly isolated by `-n` during verification.

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…rixorigin#26795)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

Fixes matrixorigin#26072

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

### Root cause

For tables without an explicit primary key, hash-diff matching uses the
visible columns as the fake-PK identity, but the LCA SQL probe joins
through the generated hidden `__mo_fake_pk_col`. The probe selected its
cast/equality type from the first visible column instead of the hidden
key column. When the first visible column was `DOUBLE`, the generated
join became `serial(__mo_fake_pk_col) = serial(cast(... AS DOUBLE))`, so
existing LCA rows were treated as misses. `DATA BRANCH DIFF`
consequently omitted no-PK deletes and updates, and MERGE left stale
rows beside updated rows.

### Changes

- Use the hidden fake-PK column's type for fake-PK LCA probe casts and
equality predicates; real and composite primary-key paths are unchanged.
- Add a frontend unit regression that captures the generated probe SQL
for a no-PK table whose first visible column is `DOUBLE` and requires
the hidden `BIGINT UNSIGNED` key type.
- Extend the existing special-float BVT to assert no-PK DIFF emits the
NaN DELETE and `+Inf` UPDATE, preserves the unchanged `-Inf` row, and
that MERGE removes/replaces the corresponding destination rows. The same
case continues to cover all three special values through primary-key
`OUTPUT AS`, MERGE, PICK, and portable SQL behavior.

### Issue-to-test proof

- `pkg/frontend/data_branch_hashdiff_test.go`: directly proves the
corrected LCA join SQL for the failing no-PK schema shape.
-
`test/distributed/cases/git4data/branch/edge/branch_float_special_values.sql`:
proves the no-PK NaN deletion, `+Inf` update, `-Inf` preservation, and
final MERGE state, in addition to the original primary-key cases for all
three special values.

### Tests run

- `make build`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=120s
-run
'^TestHandleDelsOnLCA_SQLPaths/fake_pk_sql_builder_uses_the_hidden_key_type$'
./pkg/frontend`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=180s
-run '^(TestHandleDelsOnLCA_SQLPaths|TestHashDiff_)' ./pkg/frontend`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s
./pkg/frontend`
- `GOWORK=off go vet -mod=readonly ./pkg/frontend` with the repository
CGo include/library paths
- `branch_float_special_values.sql` through mo-tester: 257/257 passed
with `-n -r 100`
- `merge_8.sql` through mo-tester: 172/172 passed with `-n -r 100`

The BVT runs use `-n` because current result metadata contains unrelated
version-dependent width differences; all SQL result values and ordering
were compared.

### Residual risks

No API or schema behavior changes are introduced. The fix adds no
fallback path, query, or concurrency/resource-lifecycle change. The
existing BVT metadata drift remains outside this focused fix and is
explicitly isolated by `-n` during verification.

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…rixorigin#26795)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

Fixes matrixorigin#26072

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

### Root cause

For tables without an explicit primary key, hash-diff matching uses the
visible columns as the fake-PK identity, but the LCA SQL probe joins
through the generated hidden `__mo_fake_pk_col`. The probe selected its
cast/equality type from the first visible column instead of the hidden
key column. When the first visible column was `DOUBLE`, the generated
join became `serial(__mo_fake_pk_col) = serial(cast(... AS DOUBLE))`, so
existing LCA rows were treated as misses. `DATA BRANCH DIFF`
consequently omitted no-PK deletes and updates, and MERGE left stale
rows beside updated rows.

### Changes

- Use the hidden fake-PK column's type for fake-PK LCA probe casts and
equality predicates; real and composite primary-key paths are unchanged.
- Add a frontend unit regression that captures the generated probe SQL
for a no-PK table whose first visible column is `DOUBLE` and requires
the hidden `BIGINT UNSIGNED` key type.
- Extend the existing special-float BVT to assert no-PK DIFF emits the
NaN DELETE and `+Inf` UPDATE, preserves the unchanged `-Inf` row, and
that MERGE removes/replaces the corresponding destination rows. The same
case continues to cover all three special values through primary-key
`OUTPUT AS`, MERGE, PICK, and portable SQL behavior.

### Issue-to-test proof

- `pkg/frontend/data_branch_hashdiff_test.go`: directly proves the
corrected LCA join SQL for the failing no-PK schema shape.
-
`test/distributed/cases/git4data/branch/edge/branch_float_special_values.sql`:
proves the no-PK NaN deletion, `+Inf` update, `-Inf` preservation, and
final MERGE state, in addition to the original primary-key cases for all
three special values.

### Tests run

- `make build`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=120s
-run
'^TestHandleDelsOnLCA_SQLPaths/fake_pk_sql_builder_uses_the_hidden_key_type$'
./pkg/frontend`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=180s
-run '^(TestHandleDelsOnLCA_SQLPaths|TestHashDiff_)' ./pkg/frontend`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s
./pkg/frontend`
- `GOWORK=off go vet -mod=readonly ./pkg/frontend` with the repository
CGo include/library paths
- `branch_float_special_values.sql` through mo-tester: 257/257 passed
with `-n -r 100`
- `merge_8.sql` through mo-tester: 172/172 passed with `-n -r 100`

The BVT runs use `-n` because current result metadata contains unrelated
version-dependent width differences; all SQL result values and ordering
were compared.

### Residual risks

No API or schema behavior changes are introduced. The fix adds no
fallback path, query, or concurrency/resource-lifecycle change. The
existing BVT metadata drift remains outside this focused fix and is
explicitly isolated by `-n` during verification.

Co-authored-by: XuPeng-SH <[email protected]>

This branch was previously deployed

1 inactive deployment
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 size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Data Branch SQL materialization cannot preserve NaN and infinity float values

3 participants