Skip to content

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

Draft
leaves12138 wants to merge 3 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 3 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.
  • Preserve the new metadata across current serializers.

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.
  • 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

  • 92 focused paimon-core tests, including historical DataSplit and ManifestCommittable compatibility resources
  • 44 post-review core tests covering global-index refresh planning, sorted-index scanning, and data-evolution compaction
  • SortedGlobalIndexScannerTest with non-index updates, repeated compaction, and expired snapshots
  • Positional array ordering and malformed-array fallback tests
  • ChangelogCompactTaskSerializerTest with column sequence metadata
  • Spark 3 common module compilation and CopyFilesUtilTest
  • Spotless and Checkstyle for core, Flink common, and Spark common

This is a WIP draft for design and compatibility review.

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