Repository navigation
feat(table): extend incremental primary-key compaction - #1256
Merged
JingsongLi merged 4 commits intoOct 30, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Follow-up to #1255 and the remaining incremental merge-engine work from #1251. Extend incremental primary-key compaction to non-DV first-row and stateful lookup tables, plus plain partial-update/aggregation configurations whose states can safely be regrouped. Small writes can be compacted while large historical runs stay in place.
Brief change log
noneandlookup; partial-update and aggregation supportlookup, and a conservative subset ofnone/inputconfigurations.KeyValue.schemaWithLevel: append the non-null INT_LEVELto internal KV input batches, using Java's field ID. Read each row's level directly; first-row distinguishes retained lookup hits by levels above the task's output level. Remove the private file-level and lookup-base batch metadata markers.none/inputmerges only the selected states, leaving history to ordinary query merging. Enable incremental selection only when all value fields usemin,max,bool_and,bool_or, or integersumwithout checked overflow. Both engines must have no global sequence fields, and aggregation must not reset on DELETE. Partial update must ignore deletes and aggregate all value fields protected by sequence groups; ordering fields retain each group's winning sequence and cannot also be protected fields. These plain modes need no local-cache.Tests
Thirteen new integration regressions plus strengthened existing cases cover fixed/dynamic buckets, both first-row producers, stateful lookup and plain safe configurations, out-of-order global/group sequences, selected positive runs, positive-only maintenance, retained history, old snapshots, cold/warm generated-file consumption with the source object removed, unchanged before/after metadata, empty output, omitted task output-level metadata, concurrent L0 and idempotent retries. Two unit regressions cover mixed levels within one batch and the trailing
_LEVELfield's type, ID and preservation across concatenation and IPC serialization.Plain tests also run with actual local-cache disabled. Counterexamples protect first-value ordering, sparse per-column overwrite, finite floating cancellation, checked overflow and reset-on-delete. Regressions verify that global sequence fields cleared by DELETE/UPDATE_BEFORE remain NULL and that intersecting ordering/protected sequence groups cannot lose an aggregate when replayed; both counterexamples failed before the safety conditions were tightened. A lookup DELETE/reinsert case preserves tombstones and their payload. Mutation checks fail as expected when first-row copies lookup hits, drops selected positive rows, the plain safety check is bypassed (20 instead of 10), or stateful lookup caching is disabled; all mutations were restored.
4,676 library unit tests and 206 related integration tests passed with
--test-threads=4; six existing library tests were ignored. All 83 PK compaction tests passed.cargo fmt --all -- --check,git diff --check, andcargo clippy --locked -p paimon --lib --test pk_compact_test -- -D warnings -A clippy::nonminimal_boolpassed. The allowance covers existing repository findings with the local toolchain.Compared with Java source at Apache Paimon commit
5be7e2dd1f:LookupStrategy,FirstRowMergeFunctionWrapper,LookupMergeFunction,LookupChangelogMergeFunctionWrapper,AggregateMergeFunctionandPartialUpdateMergeFunction. Plain selection remains conservative where regrouping would change the existing read result.API and Format
No new public API, result fields, data format or Lookup File format. First-row now requires actual FileIO local-cache even with
changelog-producer=none; lookup tables continue to require it. Newly enabled incremental tasks carryoutput_level; older executable tasks without it must be replanned. Prepared results with matching file changes can omit task output-level metadata and recover idempotently, including empty first-row results. No task transport, whole-history fence or full-compaction API is added.Documentation
Updated the compaction guide with per-engine selection, local-cache requirements, retained/materialized state behavior, first-row empty outputs and the plain-state safety conditions.