Skip to content

feat(flink): support per-table Hadoop configuration directories - #20433

Merged
danny0405 merged 4 commits into
apache:masterfrom
cbg-wx:feature_add_hadoop_conf_dir
Oct 29, 2026
Merged

danny0405 merged 4 commits into
apache:masterfrom
cbg-wx:feature_add_hadoop_conf_dir

Conversation

@cbg-wx

@cbg-wx cbg-wx commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Describe the issue this Pull Request addresses

Closes #19191. Flink tables need to read and write a Hudi table on a different Hadoop cluster without replacing the process-wide Hadoop configuration. The table-specific configuration must also reach metadata initialization.

Summary and Changelog

  • Add the optional hadoop_conf.dir table option for an explicit local Hadoop configuration directory.
  • Separate explicit-directory validation from configuration loading, without a boolean mode parameter. Validate a nonblank directory path and the presence of at least one supported regular site file (core-site.xml, hdfs-site.xml, yarn-site.xml or mapred-site.xml); leave access and XML errors to loading. No directory listing or permission prechecks are needed.
  • Preserve the existing FLINK_CONF_DIR Hadoop-property overlay and apply table-level hadoop.* options last.
  • Reuse the write client's storage configuration and engine context during metadata initialization.
  • Fix style violations and add regression coverage for validation, configuration precedence, metadata propagation, and configuration-dependent batch/incremental reads.

Impact

Adds a Flink configuration option. When unset, existing environment discovery remains unchanged. The configured directory must exist at the same local path on the client, JobManager and TaskManagers. No storage-format change. Configuration loading checks four known filenames instead of listing the directory; no throughput benchmark was performed.

Risk Level

medium: configuration precedence and metadata initialization affect filesystem access. Focused regression tests cover the inherited Flink properties, invalid directories and metadata configuration/context propagation. Integration validation uses a local-backed non-local filesystem registered only in the supplied directory; this does not replace testing against a real remote Hadoop cluster.

Documentation Update

The Flink option description documents supported files, deployment requirements, fail-fast behavior, and precedence. The corresponding Hudi website configuration documentation still needs a follow-up update in the website repository; it is not included in this code PR.

Contributor's checklist

  • Read through contributor's guide
  • Enough context is provided in the sections above
  • Adequate tests were added if applicable

Testing

  • Passed: 22 focused unit tests in TestFlinkClientUtil, TestHoodieFlinkTableServiceClient and TestHadoopConfigurations with Java 11 / Flink 2.2.
  • Passed: Checkstyle and Apache RAT checks in the focused Maven reactor build.
  • Passed: all five affected ITTestHoodieDataSource integration tests, including metadata-enabled write/read and incremental read using a filesystem registered only in hadoop_conf.dir.
  • Not run: the full repository test suite, real remote-HDFS deployment tests, or performance benchmarks.

@github-actions github-actions Bot added the size:L PR with lines of changes in (300, 1000] label Oct 25, 2026
@codecov-commenter

codecov-commenter commented Oct 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.62500% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.84%. Comparing base (62bae02) to head (de48000).
⚠️ Report is 16 commits behind head on master.

Files with missing lines Patch % Lines
...ain/java/org/apache/hudi/util/FlinkClientUtil.java 87.50% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #20433      +/-   ##
============================================
+ Coverage     80.82%   80.84%   +0.01%     
- Complexity    35912    36052     +140     
============================================
  Files          2575     2575              
  Lines        146762   147254     +492     
  Branches      17984    18303     +319     
============================================
+ Hits         118627   119046     +419     
- Misses        19997    20014      +17     
- Partials       8138     8194      +56     
Components Coverage Δ
hudi-common 84.19% <ø> (+0.01%) ⬆️
hudi-client 84.00% <ø> (+<0.01%) ⬆️
hudi-flink 86.23% <90.62%> (+0.08%) ⬆️
hudi-spark-datasource 74.24% <ø> (+0.04%) ⬆️
hudi-utilities 79.28% <ø> (+0.06%) ⬆️
hudi-cli 70.80% <ø> (ø)
hudi-hadoop 71.18% <ø> (+<0.01%) ⬆️
hudi-sync 77.31% <ø> (+0.02%) ⬆️
hudi-io 81.62% <ø> (+0.04%) ⬆️
hudi-timeline-service 83.41% <ø> (ø)
hudi-cloud 81.01% <ø> (ø)
hudi-kafka-connect 57.90% <ø> (ø)
Flag Coverage Δ
common-and-other-modules 52.30% <90.62%> (-0.03%) ⬇️
flink-integration-tests 49.69% <90.62%> (+0.03%) ⬆️
hadoop-mr-java-client 43.94% <ø> (-0.02%) ⬇️
integration-tests 13.14% <0.00%> (-0.02%) ⬇️
spark-client-hadoop-common 37.64% <ø> (-0.07%) ⬇️
spark-java-tests 51.50% <ø> (+0.03%) ⬆️
spark-scala-tests 46.46% <ø> (-0.08%) ⬇️
utilities 37.68% <ø> (+0.02%) ⬆️

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

Files with missing lines Coverage Δ
...che/hudi/client/HoodieFlinkTableServiceClient.java 73.25% <ø> (-0.31%) ⬇️
...va/org/apache/hudi/configuration/FlinkOptions.java 100.00% <100.00%> (ø)
...pache/hudi/configuration/HadoopConfigurations.java 83.33% <100.00%> (+2.08%) ⬆️
...ain/java/org/apache/hudi/util/FlinkClientUtil.java 79.24% <87.50%> (+32.57%) ⬆️

... and 44 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.

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

Reviewed commit 5f702c6 for CI failures, correctness, performance, and simplification. The configuration issues below should be addressed before merging.

CI findings:

  • test-flink-1, test-flink-2, integration-tests, and Flink 2.2 bundle validation all stop at Checkstyle in FlinkClientUtil.java:92: if (hadoopConf == null){. These are build failures before the affected test suites execute, not test assertion failures. Example: https://github.com/apache/hudi/actions/runs/40188806680/job/121155173710
  • validate-pr-and-source reports an empty Risk Level and a title missing an accepted prefix. Documentation Update also needs completing. Please provide an accurate risk assessment/documentation plan and use an accepted title convention, such as feat: .... Log: https://github.com/apache/hudi/actions/runs/40188806688/job/121155173602
  • Duplicate imports, a wildcard import, indentation inconsistencies, and }else also need cleaning up. Run Checkstyle across both changed modules after fixing the first error.

Performance: no clear throughput regression found by source inspection. The unset-option path is essentially unchanged. The configured path adds directory validation/listing on each configuration construction; checking the four supported filenames directly would avoid that scan. No benchmarks were run.

Simplification:

  • Remove the null fallback in HadoopConfigurations: the new getHadoopConf(String) overload always returns a non-null configuration.
  • Correct the comment claiming invalid directories fall back; validation throws instead.
  • Share supported filenames and common configuration-overlay logic between validation/loading paths.

Validation scope: CI logs and source inspection only; no local tests or benchmarks were run.

org.apache.hadoop.conf.Configuration hadoopConf;
if (hadoopConfDir != null) {
validateHadoopConfDir(hadoopConfDir);
org.apache.hadoop.conf.Configuration dirHadoopConf= FlinkClientUtil.getHadoopConf(hadoopConfDir);

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.

[P1] Propagate this configuration through metadata initialization too. The main write client receives this configuration, but StreamWriteOperatorCoordinator.start() also invokes initMetadataTable(). HoodieFlinkTableServiceClient.initMetadataWriter() still calls the no-argument FlinkClientUtil.getHadoopConf() and uses HoodieFlinkEngineContext.DEFAULT (HoodieFlinkTableServiceClient.java:188-190). With metadata enabled and a remote HA nameservice defined only in hadoop_conf.dir, the metadata path lacks that configuration. This existing bypass leaves the new feature incomplete. Reuse the client's storage configuration/context and add a metadata-enabled cross-cluster propagation test.


public static org.apache.hadoop.conf.Configuration getHadoopConf(String hadoopConfDir) {
org.apache.hadoop.conf.Configuration hadoopConf;
hadoopConf = getHadoopConfiguration(hadoopConfDir);

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.

[P2] Preserve the common Flink Hadoop-property overlay. The existing no-argument method applies prefixed Hadoop properties from FLINK_CONF_DIR at lines 73-83, but this overload bypasses that step. Enabling hadoop_conf.dir therefore drops properties supplied through Flink configuration even when the specified directory does not replace them, potentially losing authentication or filesystem settings. Share the overlay logic, define precedence, and test a property supplied only through Flink configuration.

"Invalid '%s': the specified path is not a directory: %s",
optionKey, dir.getAbsolutePath()));
}
File[] siteFiles = dir.listFiles((d, name) -> name.endsWith("-site.xml"));

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.

[P2] Validate the files the loader actually supports. This accepts any name ending in -site.xml, but getHadoopConfiguration() reads only core-site.xml, hdfs-site.xml, yarn-site.xml, and mapred-site.xml. A directory containing only hive-site.xml passes validation while contributing no configuration, allowing the default/environment filesystem to be used despite the promised fail-fast behavior. Check supported readable regular files, share the filename set with the loader, and test a directory containing only an unsupported site file.

public void testWriteAndReadWithHadoopConfDir() throws Exception {
File hadoopConfDir = createHadoopConfDirWithFileFs();

StoragePath path = new StoragePath(tempFile.toURI());

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.

[P2] Make the integration tests depend on the supplied configuration. This uses a fully qualified file: table path, and the helper sets fs.defaultFS=file:///. Both positive tests can succeed even when downstream components ignore hadoop_conf.dir. Exercise a filesystem/nameservice usable only with the supplied configuration, including metadata-enabled writes, and assert expected records. Also, testHadoopOptionOverridesConfDir puts hadoop.test.prop only in Flink options, not XML, so it does not test overriding a conflicting XML value.

@danny0405 danny0405 changed the title Add Hadoop configuration directory hadoop_conf.dir support for Flink cross-cluster Hudi read/write feat(flink): add Hadoop configuration directory hadoop_conf.dir support for Flink cross-cluster Hudi read/write Oct 29, 2026
@danny0405 danny0405 changed the title feat(flink): add Hadoop configuration directory hadoop_conf.dir support for Flink cross-cluster Hudi read/write feat(flink): support per-table Hadoop configuration directories Oct 29, 2026
@danny0405
danny0405 merged commit ecb7e8f into apache:master Oct 29, 2026
19 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L PR with lines of changes in (300, 1000]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a configuration to support flink reading and writing hudi tables across hadoop clusters

3 participants