Bound the sorted-scan merge by how many files' key ranges overlap
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 15/100
Research direction
Start with IcebergDataSource and StreamingMergeBuilder, then review DataFusion's split_groups_by_statistics for the overlap grouping approach. The issue says per-file column statistics on FileScanTask and an iceberg-rust revision bump are prerequisites; the maintainer is preparing that change. Done means sorted scans bound the merge by maximum file range overlap, preserve sort-key and null ordering, and safely handle missing or promoted-type bounds; this work is already underway.
Written by the indexing model from the issue text.
Description
With iceberg.execution.preserve_data_ordering, #55 merges one reader per data file with every file open at once, so iceberg.execution.max_merge_files_per_partition caps the number of files. A sorted table with many small commits goes over the cap and loses its order, even when most of its files don't overlap.
The plan is to bound the merge by overlap instead of file count. IcebergDataSource would read each file's bounds and null counts for the sort columns, sort the files by their first key in output order, and put each file after the first chain whose last file ends at or before it. DataFusion's split_groups_by_statistics does the same. Each chain is read one file at a time, the chains are k-way merged, and max_merge_files applies to the number of chains, which equals the maximum overlap depth. A table whose files don't overlap then merges nothing.
Cases that need care:
- Files are compared over every claimed sort key, not just the leading one. With a tie on the leading key, comparing only that key could put one file's rows ahead of the other's when the second key says otherwise.
- Under NULLS FIRST a file with nulls can only start a chain, and under NULLS LAST it can only end one. A missing null count on an optional column counts as nulls.
- Descending keys swap the bounds.
- Truncated string bounds stay correct; they just overlap more.
- A file with missing bounds, or a bound typed differently from the column after a type promotion, gets a chain of its own. With no bounds at all, the scan behaves exactly as after #55.
- Listing every file at planning time also needs a cap of its own.
This needs per-file column statistics on FileScanTask, which iceberg-rust doesn't carry today. That change is apache/iceberg-rust#3422, in PR apache/iceberg-rust#3424. Once it merges, this needs a bump of the iceberg-rust rev.
Related: In https://github.com/apache/datafusion-comet/pull/5331#discussion_r3830848772, @mbutrovich proposed admitting unopened files from a priority queue ordered by min bound. That bounds open readers by the same overlap depth and opens files later, which helps LIMIT, but it needs a custom merge operator. Chains reuse StreamingMergeBuilder, so I'd start there and keep admission as a possible next step.
I'm working on this and will put up the PR here once #55 and the iceberg-rust change have merged.
- Dominant language
- Rust
- Stars
- 30
- Forks
- 30
- Avg merge
- 3d 19h
- Merged PRs (30d)
- 15
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/datafusion-iceberg
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
apache/datafusion-iceberg#100 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
apache/datafusion-iceberg#85 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
apache/datafusion-iceberg#84 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
apache/datafusion-iceberg#75 ·
Maintainers usually reply within 1 day
-
Slow CI runnersOpen
Difficulty 4/5 3-5 days Newbie friendliness 18/100
apache/datafusion-iceberg#74 ·
Maintainers usually reply within 1 day
All issues in apache/datafusion-iceberg
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 1 day
-
🐞 bug 🧩 bevy_gantz_egui
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
nannou-org/gantz#500 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
metasequoiaime/msime#10989 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
fritzprix/libr-agent#2612 ·
Maintainers usually reply within 1 day
-
find: -printf %h drops a doubled slashPossibly taken @qodelicious claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day