Skip to content

[core] Pack multiple files into one split for format table reads - #8317

Merged
JingsongLi merged 2 commits into
apache:masterfrom
Zouxxyy:xinyu/format-multifile-split
Jun 22, 2026
Merged

[core] Pack multiple files into one split for format table reads#8317
JingsongLi merged 2 commits into
apache:masterfrom
Zouxxyy:xinyu/format-multifile-split

Conversation

@Zouxxyy

@Zouxxyy Zouxxyy commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Purpose

Format tables (format-table.implementation = paimon) currently generate one split per data file, which produces a large number of splits/tasks when a directory contains many small files.

This change lets a single split carry multiple files, packed in the core scan by source.split.target-size (with source.split.open-file-cost as a per-file weight floor, mirroring AppendOnlySplitGenerator). Because packing happens in FormatTableScan, it is engine-agnostic; the reader concatenates a split's files via ConcatRecordReader.

  • FormatDataSplit now holds a List<FileMeta> (path/size/offset/length) instead of a single file, with files()/partition()/totalSize()/fileCount().
  • FormatTableScan#createSplits sorts files by path for deterministic packing and bin-packs segments with max(readSize, openFileCost) as the weight; large CSV/JSON offset-slicing is preserved.
  • FormatReadBuilder#createReader builds one reader per file and chains them with ConcatRecordReader.
  • On Spark, SplitUtils reports size/file-count over the multi-file split, and each FormatDataSplit maps to one input partition (no extra re-packing).

Tests

  • New e2e in PaimonFormatTableTest: with the default target size three files pack into one split; with target size = one file size each file becomes its own split; query results are unchanged in both cases.
  • Updated FormatDataSplitTest / FormatReadBuilderTest / FormatTableScanTest for the multi-file API. All core format tests pass (61) and the Spark format-table suite passes (16).

Zouxxyy and others added 2 commits June 22, 2026 15:56
Format tables (format-table.implementation = paimon) previously generated
one split per data file, producing many splits/tasks for directories with
many small files.

FormatTableScan now packs multiple files into a single FormatDataSplit by
source.split.target-size, using max(readSize, source.split.open-file-cost)
as the per-file weight (mirrors AppendOnlySplitGenerator); files are sorted
by path so packing is deterministic. FormatReadBuilder reads the files in a
split sequentially via ConcatRecordReader. Packing lives in the core scan,
so it is engine-agnostic and each FormatDataSplit maps to one Spark input
partition without re-packing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@JingsongLi JingsongLi 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.

+1

@JingsongLi
JingsongLi merged commit 8b589d4 into apache:master Jun 22, 2026
12 checks passed
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