Skip to content

[Iceberg compaction] Rewrite planner transform - #39707

Open
ahmedabu98 wants to merge 1 commit into
apache:masterfrom
ahmedabu98:compaction-planner
Open

[Iceberg compaction] Rewrite planner transform#39707
ahmedabu98 wants to merge 1 commit into
apache:masterfrom
ahmedabu98:compaction-planner

Conversation

@ahmedabu98

@ahmedabu98 ahmedabu98 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Part of #39221

Adds a transform that plans the rewrite, and adds a configuration class defining rewrite options

Requires #39706


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@github-actions

Copy link
Copy Markdown
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@ahmedabu98 ahmedabu98 reopened this Aug 11, 2026
@ahmedabu98 ahmedabu98 changed the title [Iceberg compaction] Rewrite configuration and Planning transform [Iceberg compaction] Rewrite planner transform Aug 11, 2026

String partitionPath = table.spec().partitionToPath(group.info().partition());
partitionPaths.add(partitionPath);
int commitKey = 0;

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.

Could you help me to understand why commitKey is hardcoded to 0 ? @ahmedabu98

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code got updated since you reviewed. it's now a round robin commitKey = plannedGroupIndex % maxCommits

List<FileScanTask> tasks, long splitSize) {
long effectiveSplitSize = Math.max(1L, splitSize);
return TableScanUtil.planTaskGroups(
tasks, effectiveSplitSize, /* lookback= */ 10, /* openFileCost= */ 0L);

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.

With openFileCost=0, weight is bytes only, so the number of files per bin is unbounded.

Say 200,000 × 1 KB files in one partition, becomes one parent group, one bin, one subgroup rewritten by a single worker.

use a configurable openFileCost instead of 0 could be better. What do you think ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC openFileCost is meant for scan planning. Here we're trying to make batches that will produce target output file sizes. In this case we're intentionally making it bytes-only. Otherwise factoring in the openFileCost per file may give us groups where the real output size is much smaller than the calculated one, because it's eaten up by the apparent weight from openFileCost.

The edge case you bring up could happen though. Maybe we should expose a "max files per subgroup" option

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note Iceberg 1.11.0 added a max-file-group-input-files option: https://github.com/apache/iceberg/blob/dcd9feebbc46d6f64a25461654b83f3028f80971/core/src/main/java/org/apache/iceberg/actions/SizeBasedFileRewritePlanner.java#L110-L117

In our case, this would help control the parent group's file count

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants