Skip to content

[core] Support row-count based data file rolling (write.target-row-num-per-file)#8739

Open
XiaoHongbo-Hope wants to merge 4 commits into
apache:masterfrom
XiaoHongbo-Hope:de_row_rolling
Open

[core] Support row-count based data file rolling (write.target-row-num-per-file)#8739
XiaoHongbo-Hope wants to merge 4 commits into
apache:masterfrom
XiaoHongbo-Hope:de_row_rolling

Conversation

@XiaoHongbo-Hope

@XiaoHongbo-Hope XiaoHongbo-Hope commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Purpose

Files roll by size only. On data-evolution tables with very wide rows (vector/embedding
columns), a size-bounded file still holds too many rows, so a later add-column /
update-by-row-id OOMs materializing that row range. Adds a Lance-style
max_rows_per_file.

  • New option write.target-row-num-per-file (default Long.MAX_VALUE, disabled). Rolls on row
    count or target-file-size, whichever is reached first; bundle-granular. Validated
    positive at table create / alter.
  • Write path only: the append writer (including the dedicated BLOB/vector writer) and
    the PK data writer roll into row-bounded files, so a later add-column materializes
    bounded ranges.

Scope: bounds files at write time only. Compaction stays size-based (PK / changelog /
append all unchanged) and DE compaction still emits a single file. PyPaimon has no
row-count rolling yet, so its writer fails fast rather than silently ignoring the
option. Row-aware compaction is a follow-up.

Tests

New test methods added in this PR:

  • RollingFileWriterTest#testRollingByRows, #testRollingByRowsWithBundle
  • DedicatedFormatRollingFileWriterTest#testRollingByRows
  • KeyValueFileReadWriteTest#testMergeTreeCompactionIgnoresRowLimit
  • DataEvolutionTableTest#testDataEvolutionWriteRollsByRows, #testDataEvolutionReadWithRolledColumns
  • SchemaValidationTest#testWriteTargetRowNumPerFileMustBePositive
  • reader_append_only_test.py::test_write_target_row_num_per_file_fails_fast

@XiaoHongbo-Hope
XiaoHongbo-Hope force-pushed the de_row_rolling branch 4 times, most recently from db36b3a to 475bb07 Compare July 22, 2026 11:02
@XiaoHongbo-Hope
XiaoHongbo-Hope marked this pull request as ready for review July 22, 2026 12:05
@XiaoHongbo-Hope
XiaoHongbo-Hope marked this pull request as draft July 22, 2026 12:15
Files roll by size only today. On data-evolution tables with very wide rows
(e.g. vector/embedding columns), a size-bounded file still holds too many rows,
so a later add-column / update-by-row-id OOMs materializing that row range.
Lance handles this with max_rows_per_file; this adds the same to Paimon.

- New option target-file-num-rows (default Long.MAX_VALUE, disabled). Rolls on
  row count or target-file-size, whichever first; bundle-granular. Validated to be
  positive at table creation / alter (SchemaValidation).
- Applied to the write path only: the append writer (incl. the dedicated
  BLOB/vector writer) and the PK data + changelog writers. Data-evolution base
  writes therefore roll into row-bounded files, so a later add-column
  materializes bounded ranges.

Scope: this bounds files at write time. Compaction is left unchanged (size-based)
and data-evolution compaction still merges into a single file -- making compaction
row-aware (append/bucketed/clustering selection, DE multi-output, DV handling)
needs careful, contiguity-preserving work and is left as a follow-up. PyPaimon
support is also a follow-up.

Tests: RollingFileWriterTest#testRollingByRows/#testRollingByRowsWithBundle,
DedicatedFormatRollingFileWriterTest#testRollingByRows,
DataEvolutionTableTest#testDataEvolutionWriteRollsByRows/#testDataEvolutionReadWithRolledColumns,
SchemaValidationTest#testTargetFileNumRowsMustBePositive.
Gate target-file-num-rows to the write path only: merge-tree
compaction (FileSource.COMPACT) and changelog writers ignore the
row cap so compaction stays size-based. Clarify the option
description accordingly and regenerate docs. pypaimon has no
row-count rolling yet, so its writer now fails fast when the
option is set instead of silently ignoring it.
@XiaoHongbo-Hope
XiaoHongbo-Hope marked this pull request as ready for review July 23, 2026 03:53
Comment thread paimon-core/src/main/java/org/apache/paimon/append/AppendOnlyWriter.java Outdated
@XiaoHongbo-Hope XiaoHongbo-Hope changed the title [core] Support row-count based data file rolling (target-file-num-rows) [core] Support row-count based data file rolling (target-row-num-per-file) Jul 23, 2026
@XiaoHongbo-Hope XiaoHongbo-Hope changed the title [core] Support row-count based data file rolling (target-row-num-per-file) [core] Support row-count based data file rolling (write.target-row-num-per-file) Jul 23, 2026
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