[core] Pack multiple files into one split for format table reads - #8317
Merged
Conversation
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>
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
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(withsource.split.open-file-costas a per-file weight floor, mirroringAppendOnlySplitGenerator). Because packing happens inFormatTableScan, it is engine-agnostic; the reader concatenates a split's files viaConcatRecordReader.FormatDataSplitnow holds aList<FileMeta>(path/size/offset/length) instead of a single file, withfiles()/partition()/totalSize()/fileCount().FormatTableScan#createSplitssorts files by path for deterministic packing and bin-packs segments withmax(readSize, openFileCost)as the weight; large CSV/JSON offset-slicing is preserved.FormatReadBuilder#createReaderbuilds one reader per file and chains them withConcatRecordReader.SplitUtilsreports size/file-count over the multi-file split, and eachFormatDataSplitmaps to one input partition (no extra re-packing).Tests
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.FormatDataSplitTest/FormatReadBuilderTest/FormatTableScanTestfor the multi-file API. All core format tests pass (61) and the Spark format-table suite passes (16).