Repository navigation
fix(frontend): use hidden fake pk type for data branch lca probe - #26795
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
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.
…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]>
…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]>
…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]>
What type of PR is this?
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 wasDOUBLE, the generated join becameserial(__mo_fake_pk_col) = serial(cast(... AS DOUBLE)), so existing LCA rows were treated as misses.DATA BRANCH DIFFconsequently omitted no-PK deletes and updates, and MERGE left stale rows beside updated rows.Changes
DOUBLEand requires the hiddenBIGINT UNSIGNEDkey type.+InfUPDATE, preserves the unchanged-Infrow, and that MERGE removes/replaces the corresponding destination rows. The same case continues to cover all three special values through primary-keyOUTPUT 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,+Infupdate,-Infpreservation, 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/frontendGOWORK=off go vet -mod=readonly ./pkg/frontendwith the repository CGo include/library pathsbranch_float_special_values.sqlthrough mo-tester: 257/257 passed with-n -r 100merge_8.sqlthrough mo-tester: 172/172 passed with-n -r 100The BVT runs use
-nbecause 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
-nduring verification.