Skip to content

[core] Refresh single-source Data Evolution ROW materializations - #11540

Merged
JingsongLi merged 3 commits into
apache:masterfrom
JingsongLi:codex/paimon-data-evolution-row-refresh
Nov 30, 2026
Merged

JingsongLi merged 3 commits into
apache:masterfrom
JingsongLi:codex/paimon-data-evolution-row-refresh

Conversation

@JingsongLi

Copy link
Copy Markdown
Contributor

Purpose

Refresh a dedicated ROW Data Evolution table from a single Data Evolution source using the Java API. The caller provides a deterministic projection and optional filter. The target stores the source row ID with each projected row.

The refresher pins the source snapshot and uses DataEvolutionChangePlanner to find affected row ranges. It replaces changed target rows and records removed rows in target deletion vectors. TableCommitImpl.commitRefresh publishes the data, deletion vectors, and applied source snapshot ID together. A refresh with no row changes can still advance the cursor.

Bootstrap and missing source history use a full overwrite. The caller serializes refreshes and other writes to the dedicated target.

This is the next Core step for incremental materialized refresh, extracted from #11515 after #11539.

Tests

Maven packaging passed with 442 targeted tests across Common and Core. Six end-to-end tests cover initial ROW materialization, partial-column updates and cursor-only advancement, DV-only deletes and historical target reads, retry after publication loses its acknowledgement, progress through maintenance commits, and full rebuilds after source history expires.

@leaves12138 leaves12138 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 master at head ba8096e. Full file list (10 files): paimon-api/RefreshState.java, paimon-common/utils/Range.java (+test), paimon-core (AppendDeleteFileMaintainer, FileStoreCommit, FileStoreCommitImpl, new table/materialized/DataEvolutionMaterializedTableRefresh), and tests (SnapshotTest, FileStoreCommitTest, new DataEvolutionMaterializedTableRefreshTest).

Core change notice: beyond the new experimental refresher, this touches shared core contracts: RefreshState gains optional UUID and schema-version maps (snapshot JSON, NON_EMPTY so legacy payloads are unchanged and id-only states round-trip equal), Range.coalesceSorted is a new general utility, AppendDeleteFileMaintainer now reconciles mixed Bitmap/Bitmap64 DVs on merge, and FileStoreCommitImpl adds a typed lock-acquisition failure for refresh commits. All DV maintainers and refresh-state readers are affected.

Analysis:

  • Identity safety: the cursor key is table UUID + branch; advancement requires matching snapshot ID AND UUID AND a schema version that hashes the projected input RowType JSON, so snapshot-ID reuse after rollback and schema-ID reuse after schema rollback both force a full rebuild (dedicated tests). The source snapshot manager cache is invalidated to see rollbacks through other handles.
  • Incremental path: changed ranges split at start.nextRowId so only pre-existing IDs are looked up in the target; the lookup uses coalesced BETWEEN bounds (largest gaps preserved, unsigned gap comparison handles signed extremes) for pruning but re-checks exact IDs after reading, and a 16 MiB budget overflow falls back to full overwrite instead of unbounded memory.
  • Write path: rows unchanged after projection are skipped; changed/removed old rows become target DV positions located via merged file-group anchors with bounds checks; deletes are staged per partition through the unaware-append maintainer with prior index entries and withCheckFromSnapshot(base.id()), so concurrent target modification conflicts rather than corrupting DVs. The mixed-bitmap merge upgrades to Bitmap64 in either direction.
  • Failure handling: staged files are aborted on write failure; a CommitLockAcquisitionException only aborts when no attempt could have published (retryResult == null) and the commit user matches, so an unknown-outcome publication is never cleaned up — covered by the parameterized lock-failure test and the lost-acknowledgement retry test.
  • Full overwrite disables dynamic partition overwrite so an empty rebuild clears all target partitions (tested); progress-only refreshes advance the cursor via #11536 semantics; target maintenance commits carry progress (tested).
  • Guardrails are strict: dedicated ROW+DV Data Evolution target, no defaults/generated columns, no BLOB inline fields, single branch, no time travel, no query auth, no ignore-lost/corrupt options, current-schema check on both tables. Caller-serialized writes are documented.

No findings. Thirteen end-to-end tests cover bootstrap, partial columns, DV deletes with historical reads, rebuild triggers (ID reuse, schema change, missing history, budget), bitmap migration, lock abort, blob descriptors, retry, and metadata-commit progress.

CI note: checks are still initializing on this head; the author ran 442 targeted Common/Core tests locally. Approving without waiting for CI.

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants