Repository navigation
fix(data branch): use lineage mapping for diff output tables - #32971
mergify[bot] merged 3 commits into
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? |
|
Queue requested — the merge queue status continues in this comment ↓. |
|
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: dc1dc9e637970be0ced7bb9c6a546d97a4bd0a84
Assessment: approve
The output table now uses the reconciled column mapping, preserves target column order, and writes NULL for target-only fields on base rows. Fallback reads preserve the input key order, and fixed-offset inserts preserve timestamp instants across DST folds and the year-9999 boundary.
Model: gpt-6.2-sol / xhigh
Session: 01a1f0a0-5126-78f3-9ab8-ef4e87f2f119 · slot 0 · generation 3
Validation:
-
Verified the frozen checkout, patch, and git diff --check. Private /tmp and loopback preflight passed. Native build inputs matched the retained build ledger.
-
All 404 selected frontend tests and subtests passed, including all-hit row ordering, historical projection, Unicode name handling, decimal attributes, timestamp round-trips, and cleanup after insert failure. See frontend-tests-retry.log and checks/1795243073638998415-3.json.
-
A two-CN embedded MySQL probe verified persisted values after COPY ALTER, both DST-fold instants, a timestamp beyond UTC year 9999, session time-zone preservation, and rejection of incompatible decimal attributes before table creation. See public-sql.log and checks/1795243142135552921-3.json.
-
Frozen CI reports successful Ubuntu unit tests and both BVT jobs. The repository selector assigns the changed SQL case to BVT group 1.
Limitations:
- The local public SQL check covered focused scenarios. Detailed author BVT counts apply to pre-merge revision 6f357bb, and the frozen CI evidence provides job-level status.
✅ Merged into
|
## What type of PR is this? - [x] BUG ## Which issue(s) this PR fixes: issue #32003 ## What this PR does / why we need it: An unconditional DELETE can use the same physical table replacement path as TRUNCATE. Data Branch previously recorded that replacement as row-preserving ALTER lineage. Subsequent DIFF and PICK could retain changes from the cleared generation without seeing the implied deletions. In the reported sequence, PICK returned success without restoring the requested row. Record clear boundaries in existing branch lineage metadata and reconstruct changes against the appropriate comparison snapshot. Keep COPY ALTER row-preserving; do not infer clear boundaries retroactively from legacy ALTER records or missing history. - Apply both halves of a mixed PICK batch: restore independently deleted keys and still update the surviving keys. - In bounded PICK across a clear, limit insert/update columns to the source layout at the upper snapshot. Preserve destination values for later columns on UPDATE and use destination defaults on INSERT. - Reject matching-row comparisons when a shared column's historical introduction value cannot be reconstructed, rather than silently treating it as unchanged. Validation on `f42550e540b` (base `dc204213996`, including #32970 and #32971): - All three review cases reproduced on `8734ac51866` and were added to `test/distributed/cases/git4data/branch/merge/merge_issue_32003.sql`. - 295 focused unit tests and embedded SQL `TestDataBranchAfterTableClear` / `TestDataBranchClearBoundaryAfterGC` passed. - Exact-head local BVT: 385/385 statements, no skips. This covers `merge_issue_32003`, `branch_rebuild_lifecycle`, `diff_older_ancestor_snapshot` and `diff_output_as_altered_columns`. Validation on `ee35455eb5a`: - The bounded PICK hydration regression checks both an upper snapshot before the ALTER and one at the ALTER. Both assert that the upper-snapshot relation supplies the renamed and newly added column values, while preserving the row ID and commit timestamp. Six related frontend tests passed in three consecutive local runs. - The previously failing Ubuntu unit and coverage jobs on `5f5b752c299` both stopped at the stale upper-snapshot mock expectation. CI for the new head is tracked separately. QA required: yes. The fix changes persisted lineage interpretation and SQL-visible Data Branch behavior. Local SQL verifies final rows and error outcomes, including restart/GC coverage. Multi-CN/Proxy on the PR head remains pending. Approved-by: XuPeng-SH <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
issue #32969
What this PR does / why we need it:
Summary
Fixes
DATA BRANCH DIFF ... OUTPUT ASschema evolution / column lineage resolution bugs and fixes related column mapping, row ordering,TIMESTAMPformatting,DECIMALattribute, and Unicode case-fold edge cases.Root Cause & Changes
OUTPUT ASDDL & base history projection (pkg/frontend/data_branch.go,pkg/frontend/data_branch_hashdiff.go,pkg/frontend/data_branch_output.go):reconcileDataBranchEndpointSchemato index target data columns positionally (tarDataIdxskippingcatalog.Row_ID), populatelcaColNames,baseColNames, andbaseColToTarIdxaccurately across altered/renamed/reordered schemas, and keepdataBranchIndexedSpecialUpdateColIdxesconsistent viacommonutil.EqualFoldKey.excludeTargetOnlyindataBranchSourceColToTargetIdxso base-side historical batches exclude target-only slots instead of leaking or failing type checks acrossCOPY ALTER.diffOutputTable.createSQL/materializeDiffOutputAsTableto resolve target-only and renamed common columns from endpoint definitions cleanly, and preservedselsreordering inrunLCAProbeWithReaderFallbackeven whenlen(missedRows) == 0.pkg/frontend/data_branch.go,pkg/frontend/data_branch_output.go):NumericAttributeschecks todataBranchColumnTypeAttributesEqualandisDataBranchLogicalTypeEquivalent(catchingDECIMAL UNSIGNED/ZEROFILLmismatches).commonutil.EqualFoldKeyconsistently acrosscheckSchemaCompatibilityWithResolver,dataBranchLineageEndpointColumnsduplicate visible-target checks,resolveProjectedIdxes,newDiffOutputTable,nextAvailableDiffOutputColumnName, anddataBranchIndexedSpecialUpdateColIdxes, explicitly rejecting fold-equivalent visible columns (e.g.svsſ) and deduplicating output metadata columns against__mo_diff_source/__mo_diff_flagwhile preserving lowercase map keys indataBranchLineageEndpointColumnsfor existing callers.TIMESTAMPDST fold & extreme-offsetOUTPUT ASmaterialization (pkg/frontend/data_branch_output.go):OUTPUT ASTIMESTAMPliterals with sticky per-row negative fixed offsets (-rowOffsetHours) to preserve DST fall-back fold instants (e.g.,America/New_York),1970-01-01minimum storable instants under positive offsets, and year-9999values that would otherwise overflow UTC.pkg/frontend/data_branch_hashdiff_test.go,pkg/frontend/data_branch_output_test.go,test/distributed/cases/git4data/branch/diff/diff_output_as_altered_columns.{sql,result}):COPY ALTERcolumns, historical baseDROP COLUMN,runLCAProbeWithReaderFallbackselsordering, DST fold / min-maxTIMESTAMPbatching,DECIMAL UNSIGNED, and Unicode fold (s/ſ/__mo_diff_ſource) edge cases.Non-Goals / Deferred (Pre-Existing Out-of-Scope)
COPY ALTERslot collision on non-target-only columns (data_branch_hashdiff.go:3217) and pre-existing CTAS bypass ofvalidateUniquePersistedTableColumns(pkg/sql/plan/build_ddl.go:3474) are baseline behaviors untouched by this PR.QA Decision
DATA BRANCH DIFF ... OUTPUT ASschema evolution, type compatibility, and timestamp behavior fix; adds BVT suitetest/distributed/cases/git4data/branch/diff/diff_output_as_altered_columns.sql).Verification (Exact Final HEAD
6f357bbcdb9c3e9e881db12a6a975e325ef59d9b).agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=10m -run 'Test.*DataBranch|TestMaterializeDiffOutputAsTable|TestDiffOutputTable|TestLCAProbe|TestRunLCAProbe|TestCheckSchemaCompatibility|TestValidateDataBranch' ./pkg/frontend-> 404/404 PASS (160 top-level + 244 subtests, 0 failed, 0 skipped;TestValidateDataBranch*6/6,TestCheckSchemaCompatibility*22/22).make build-with-prebuilt-native->vcs.revision=6f357bbcdb9c3e9e881db12a6a975e325ef59d9b,vcs.modified=false, SHA-256a669585282cfcb7fe765045c79b27d4cbd55f0213e2afefd3d3ac9c88a404ad7verified before and after BVT.make static-check-selected STATIC_CHECK_PACKAGES=./pkg/frontend GOLANGCI_LINT_CONCURRENCY=4->0 issues..bvt-r10-final/output: focused131/131(100%), regressions (3 scripts:diff_17,diff_output_as_altered_columns,diff_schema_evolve)563/563(100%).bvt-r10-final/regressions: focused131/131(100%), regressions (55 scripts)4457/4457(100%).