Skip to content

[core][WIP] Avoid global index rebuilds for unrelated column compaction - #9069

Draft
leaves12138 wants to merge 5 commits into
apache:masterfrom
leaves12138:codex/wip-column-sequence-metadata
Draft

[core][WIP] Avoid global index rebuilds for unrelated column compaction#9069
leaves12138 wants to merge 5 commits into
apache:masterfrom
leaves12138:codex/wip-column-sequence-metadata

Conversation

@leaves12138

@leaves12138 leaves12138 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

What

  • Add an optional positional long[] of per-column maximum sequence numbers to DataFileMeta.
  • Reuse writeCols to resolve array positions; full-column files use the file schema field order.
  • Propagate the per-column sequence watermark through data-evolution normal compaction, aggregating each input field once.
  • Make global-index refresh planning compare the indexed columns' sequence watermarks instead of the compacted file's overall maximum sequence.
  • Integrate the metadata with the latest projected binary manifest scan path and keep the POJO and binary planners behaviorally identical.
  • Preserve the new metadata across current serializers and return defensive copies from POJO metadata.

Why

Data-evolution compaction rewrites a full normal data file. Today the compacted file's overall maxSequenceNumber advances when only a non-index column changes, so SortedGlobalIndexScanner treats the row range as an index-column update and rebuilds the global index unnecessarily.

Snapshot history cannot reliably answer which column changed because snapshots may already have expired. Persisting the column watermarks in file metadata makes the decision independent of retained snapshot history and lets repeated compactions carry the information forward.

Compatibility

  • The manifest field is nullable. Files written before this change fall back to the file-level maximum sequence and therefore retain the conservative rebuild behavior.
  • Missing or malformed positional arrays also fall back to the file-level maximum sequence.
  • Add a serializer for the previous 20-field DataFileMeta layout.
  • Keep the new public DataFileMeta methods as default methods so existing external implementations remain source/binary compatible.
  • Bump and route compatibility for CommitMessage, DataSplit, IncrementalSplit, ChainSplit, and SplitSerializer.
  • Add current-version golden resources for SplitSerializer v2, DataSplit v9, and ManifestCommittable v5 containing CommitMessage v13.
  • Bump explicitly savepoint-incompatible compaction task serializers, including the Flink changelog compaction task serializer.
  • When Spark sys.copy assigns a target schema id, clear the positional sequence array so readers conservatively fall back to the file-level maximum.

Impact

For data-evolution tables using global-index column update action IGNORE, compaction after updating only non-index columns no longer rebuilds an already valid global index. Updates to indexed columns still trigger refresh. Legacy files remain conservative.

Checks

  • Rebased onto the latest master, including the projected binary manifest refresh planner.
  • 95 focused paimon-core tests covering serializer compatibility, global-index refresh planning, sorted-index scanning, and data-evolution compaction.
  • SortedGlobalIndexScannerTest covers non-index updates, repeated compaction, binary/POJO planner parity, and expired snapshots.
  • Positional array ordering, defensive-copy, malformed-array fallback, and single-fetch regression coverage.
  • Flink 1.x ChangelogCompactTaskSerializerTest.
  • Spark 3 common CopyFilesUtilTest.
  • Spotless and Checkstyle for core, Flink common, and Spark common.

This is a WIP draft for design and compatibility review.

@leaves12138
leaves12138 force-pushed the codex/wip-column-sequence-metadata branch from c454d0c to 32f5174 Compare August 10, 2026 07:21
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.

1 participant