Skip to content

fix(flink): prune partitions before incremental file checks - #20995

Queued
VirtualSelect wants to merge 3 commits into
apache:masterfrom
VirtualSelect:fix/flink-incremental-partition-pruning-20989
Queued

VirtualSelect wants to merge 3 commits into
apache:masterfrom
VirtualSelect:fix/flink-incremental-partition-pruning-20989

Conversation

@VirtualSelect

Copy link
Copy Markdown

Describe the issue this Pull Request addresses

Closes #20989.

Summary and Changelog

Apply the planner's existing partition selection before building file statuses and checking storage on bounded and streaming non-CDC incremental reads. Keep the existing COW file-ID and MOR full-path lookup keys, reverse commit order, and handling of missing files within the selected partitions. No change to CDC or partition selection.

Impact

Avoids probing excluded files and prevents an excluded file removed by the cleaner from triggering the bounded full-scan fallback. No config or storage format change. No object-store latency or throughput claims.

Risk Level

Low. Added a Flink 1.20 planner regression using real local commit metadata and filesystem paths for COW and MOR. It compares unfiltered output, excludes a missing file without probing it, and exercises a missing selected file in bounded and streaming reads. Both variants failed on the pre-fix implementation at the excluded-file probe assertion and both passed with this patch (JDK 21).

Documentation Update

None.

Contributor's checklist

  • Read through the contributor's guide
  • Provided context and targeted regression tests

AI assistance was used in preparing and verifying this change.

@github-actions github-actions Bot added the size:M PR with lines of changes in (100, 300] label Nov 30, 2026

@cshuo cshuo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The pruning change looks good to me. All 28 TestIncrementalInputSplits cases passed locally on Flink 1.20.1 with JDK 21. Restoring the old planner calls made both new cases fail on the excluded par2 probe. I have two suggestions for strengthening the regression coverage.

Comment on lines +441 to +442
assertTrue(selected.inputSplits(metaClient, false).isEmpty());
assertTrue(selected.inputSplits(metaClient, null, false).isEmpty());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we keep an older committed base file in par1 when deleting the file referenced by the selected commit? With the current fixture, I changed the bounded call to ignoreMissingFiles = true and both cases still passed. With the older file present, bounded planning recovered its path and streaming returned zero splits. Asserting those two results caught the flag change for both COW and MOR.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for testing both failure modes. In 5fab315, deleting the selected instant’s file now recovers the older committed file for bounded reads and produces no streaming splits. Setting ignoreMissingFiles=true on the bounded path fails both the COW and MOR cases. The additional MOR test checks that both planning paths retain two logs for one file group; switching to file-ID lookup drops the older log and fails. All three focused cases passed on Flink 1.20.1. The wider local run was limited by the embedded timeline service’s network-dependent hostname lookup.

Comment on lines +385 to +387
for (String partition : Arrays.asList("par1", "par2")) {
String fileId = "file-" + partition;
StoragePath file = new StoragePath(FileCreateUtils.createBaseFile(metaClient, partition, instant, fileId, 100L));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could the MOR case append two distinct logs to the same selected file group in successive delta commits and assert that both paths appear in the split? With one base file per file ID, the test still passed when I routed MOR through the COW getFileIdToInfo lookup. I tried the two-commit fixture and it caught that change when the earlier log disappeared from the split.

@VirtualSelect
VirtualSelect requested a review from cshuo December 1, 2026 08:58

@cshuo cshuo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, the updated tests cover both review concerns. cc @danny0405

@codecov-commenter

codecov-commenter commented Dec 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 79.70%. Comparing base (ca40c27) to head (5fab315).
⚠️ Report is 30 commits behind head on master.

Files with missing lines Patch % Lines
...apache/hudi/common/model/HoodieCommitMetadata.java 90.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #20995      +/-   ##
============================================
- Coverage     80.95%   79.70%   -1.26%     
+ Complexity    36732    36156     -576     
============================================
  Files          2600     2600              
  Lines        149464   149486      +22     
  Branches      18630    18634       +4     
============================================
- Hits         120998   119142    -1856     
- Misses        20058    22039    +1981     
+ Partials       8408     8305     -103     
Components Coverage Δ
hudi-common 83.84% <90.00%> (-0.42%) ⬇️
hudi-client 82.43% <ø> (-1.76%) ⬇️
hudi-flink 86.42% <100.00%> (+0.08%) ⬆️
hudi-spark-datasource 70.59% <ø> (-3.88%) ⬇️
hudi-utilities 77.50% <ø> (-1.78%) ⬇️
hudi-cli 70.92% <ø> (ø)
hudi-hadoop 70.99% <ø> (-0.22%) ⬇️
hudi-sync 77.30% <ø> (+0.02%) ⬆️
hudi-io 81.43% <ø> (-0.14%) ⬇️
hudi-timeline-service 84.14% <ø> (+0.65%) ⬆️
hudi-cloud 81.01% <ø> (ø)
hudi-kafka-connect 58.40% <ø> (ø)
Flag Coverage Δ
common-and-other-modules 44.71% <88.88%> (+0.01%) ⬆️
flink-integration-tests 41.07% <77.77%> (+0.01%) ⬆️
hadoop-mr-java-client 44.47% <30.00%> (+0.04%) ⬆️
integration-tests 14.57% <0.00%> (+<0.01%) ⬆️
spark-client-hadoop-common 37.99% <0.00%> (-0.01%) ⬇️
spark-java-tests 50.46% <30.00%> (-2.18%) ⬇️
spark-scala-tests 50.23% <30.00%> (-3.32%) ⬇️
utilities 39.59% <30.00%> (-3.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...e/hudi/sink/partitioner/profile/WriteProfiles.java 68.18% <100.00%> (+8.65%) ⬆️
...org/apache/hudi/source/IncrementalInputSplits.java 89.38% <100.00%> (+5.30%) ⬆️
...apache/hudi/common/model/HoodieCommitMetadata.java 93.47% <90.00%> (-0.22%) ⬇️

... and 198 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

}

probes.clear();
assertEquals(Collections.singletonList("par1"), getFilteredPartitions(selected.inputSplits(metaClient, false)));

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 we add a second file group to par1 in commit 001 and leave it untouched in 002? I forced the bounded planner to take the full-scan fallback after a successful filtered lookup, and all three new cases still passed. With the extra group, the incremental lookup returns one split here and the full scan returns two. I tried that fixture on Flink 1.20.1. Both COW and MOR caught the forced fallback, and all three cases passed on the PR head after updating the later fallback assertion to expect both older files.

Comment on lines +420 to +421
assertEquals(Arrays.asList("par1", "par2"), getFilteredPartitions(all.inputSplits(metaClient, false)));
assertEquals(Arrays.asList("par1", "par2"), getFilteredPartitions(all.inputSplits(metaClient, null, false)));

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 these two assertions compare the partition names in any order, while still checking that each occurs exactly once? Both splits have the same latest commit, so their relative order comes from iterating the partition set. Sorting the actual names before comparing would keep the duplicate-split check and allow either valid order.

HoodieTableType tableType,
boolean ignoreMissingFiles,
@Nullable Set<String> selectedPartitions) {
Predicate<String> partitionFilter = selectedPartitions == null ? partition -> true : selectedPartitions::contains;

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 this overload take a Predicate<String> partitionFilter directly? Both planner callers can pass readPartitions::contains, and the existing unfiltered overload can pass partition -> true. That removes the nullable-set convention and this conversion while preserving the existing overloads.

Use a partition predicate and keep order-independent assertions multiplicity-aware.

Assisted-by: OpenAI ChatGPT
@VirtualSelect

Copy link
Copy Markdown
Author

Thanks for the fixture and API suggestions. 6a4c6f6d adds a second, untouched file group in par1, compares partitions without assuming iteration order (duplicates still fail), and passes a Predicate<String> while retaining the unfiltered overloads. All three focused cases passed on Flink 1.20.1. Forcing the bounded planner to fall back after a successful metadata lookup made both COW and MOR fail as intended (one par1 split expected, two observed). In the broader class run, the same 21 coordinator tests failed to start with Network is unreachable on both the prior head and this change.

@hudi-bot

hudi-bot commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

@danny0405
danny0405 added this pull request to the merge queue Dec 3, 2026

This branch has not been deployed

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

Labels

size:M PR with lines of changes in (100, 300]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Flink] Apply partition pruning before incremental file-existence checks

5 participants