Repository navigation
Conversation
Copy the 71 files of hudi-flink-datasource/hudi-flink2.2.x to hudi-flink-datasource/hudi-flink2.3.x without changes. The only difference to the source module is the artifactId in pom.xml. The module is not part of any build profile yet. The next commits add the flink2.3 profile and the changes Flink 2.3.0 needs.
Add flink2.3.version (2.3.0) and the flink2.3 profile, which builds hudi-flink-datasource/hudi-flink2.3.x and the hudi-flink2.3-bundle. Point the dependencies of hudi-flink2.3.x at flink2.3.version. As for Flink 2.2, the newest Flink version becomes the default build: flink.version, hudi.flink.module and flink.bundle.version now default to Flink 2.3, and activeByDefault moves from flink2.2 to flink2.3. The flink2.2 profile and the older ones stay available. Dependency versions of the flink2.3 profile: - Avro 1.11.4, as avro.version in flink-parent 2.3.0 - Parquet 1.15.2, as flink.format.parquet.version in flink-formats 2.3.0 - ORC 1.5.6, as orc.version in flink-parent 2.3.0 - flink-connector-kafka 5.0.0-2.2, the newest release on Maven Central; there is no release built for Flink 2.3 yet
Follow the default Flink version in the places that name it: - bot.yml: the jobs that ran with flink2.2 now run with flink2.3 - azure-pipelines-20230430.yml and hudi-lakehouse/scripts/build-jars.sh - README.md: default version, bundle table and build examples - release/release_guide.md: the release build command, which has to match the activeByDefault profiles Add the Flink 2.3 bundle to the release tooling: - maven_artifact_validation.yml and release_candidate_validation.yml - scripts/release/deploy_staging_jars.sh and validate_staged_bundles.sh - packaging/bundle-validation/ci_run.sh, with the base image tag flink230hive313spark359 and the build script for it The base image apachehudi/hudi-ci-bundle-validation-base with the tag flink230hive313spark359 is not on Docker Hub yet. The validate-bundles job for flink2.3 needs it.
…ts and the quickstart Flink 2.3 adds the ON CONFLICT clause (FLINK-38927, FLINK-38928) and the option table.exec.sink.require-on-conflict, which is true by default in Flink 2.3. The planner then rejects a streaming INSERT into a table with a primary key when the upsert key of the query differs from the primary key and the statement has no ON CONFLICT clause: ValidationException: The query has an upsert key that differs from the primary key of the sink table 'default_catalog.default_database.t1'. Primary key: [uuid], upsert key: . ... Please specify an ON CONFLICT clause to define how conflicts should be handled The Hudi sink is an upsert sink, so the plain "INSERT INTO t1 ..." statements of the tests fail at planning time with the flink2.3 profile: 88 tests of ITTestHoodieDataSource, testRemotePartitioner of ITTestBucketStreamWrite, six tests of ITTestDynamicBucketStreamWrite and all four of TestHoodieFlinkQuickstart. Set the option to false in the stream table environments that run these statements: ITTestHoodieDataSource, ITTestDynamicBucketStreamWrite, ITTestBucketStreamWrite and HoodieFlinkQuickstart. Flink versions before 2.3 do not have the option and ignore the key.
…dle validation SQL packaging/bundle-validation/flink/insert.sql creates a table with a primary key and fills it with INSERT INTO ... VALUES in streaming mode. On Flink 2.3 the planner rejects that statement, for the reason given in the previous commit (FLINK-38927, table.exec.sink.require-on-conflict). Set the option to false in the script. The SQL client of earlier Flink versions accepts the unknown key.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #20776 +/- ##
============================================
- Coverage 80.92% 80.91% -0.01%
- Complexity 36217 36221 +4
============================================
Files 2591 2591
Lines 147957 147962 +5
Branches 18315 18317 +2
============================================
- Hits 119728 119723 -5
- Misses 19937 19950 +13
+ Partials 8292 8289 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| execConf.setString("restart-strategy.fixed-delay.attempts", "0"); | ||
| // Flink 2.3 rejects an INSERT whose upsert key differs from the primary key of the sink table | ||
| // unless it has an ON CONFLICT clause (FLINK-38927), restore the behavior of earlier versions. | ||
| execConf.setString("table.exec.sink.require-on-conflict", "false"); |
There was a problem hiding this comment.
HoodieFlinkQuickstart.java:119 · HoodieTableSink.java:148–153
I’d prefer the default UPSERT branch to preserve the row kinds in requestedMode and filter out only UPDATE_BEFORE:
ChangelogMode.Builder builder = ChangelogMode.newBuilder();
for (RowKind kind : requestedMode.getContainedKinds()) {
if (kind != RowKind.UPDATE_BEFORE) {
builder.addContainedKind(kind);
}
}
return builder.build();With the current change, an insert-only streaming job that worked on 2.2 can fail at planning time on 2.3 when Flink cannot infer an upsert key for the keyed Hudi sink. Users must explicitly set table.exec.sink.require-on-conflict=false to keep the same SQL. Filtering the requested kinds keeps this input insert-only, so the job runs with default settings and avoids the extra SinkMaterializer on 2.3.0. Flink 2.4 also changed require-on-conflict to default to false to restore compatibility. Upstream change
There was a problem hiding this comment.
@cshuo Makes sense, done. getChangelogMode now uses your snippet, and I removed the require-on-conflict setting from the quickstart, the tests and insert.sql.
| IMAGE_TAG=flink221hive313spark359 | ||
| FLINK_VERSION=2.2.1 | ||
| elif [[ ${FLINK_PROFILE} == 'flink2.3' ]]; then | ||
| IMAGE_TAG=flink230hive313spark359 |
There was a problem hiding this comment.
Since you’ve already built the image locally, I suggest pushing the flink230hive313spark359 tag to your own Docker Hub repository and temporarily pointing the bundle-validation job in your fork at that image. Once validation passes on a clean CI runner, a maintainer can publish the image to apachehudi/hudi-ci-bundle-validation-base. Before merging, switch the reference back to the official repository and rerun validation to confirm CI can pull the published tag.
There was a problem hiding this comment.
@cshuo Done, I pushed it to nestdream/hudi-ci-bundle-validation-base:flink230hive313spark359 and pointed the flink2.3 validation at it for now, and validate-bundles passes in my fork: https://github.com/NestDream/hudi/actions/runs/44839263047/job/137389875404. I'll switch back once the image is on apachehudi.
There was a problem hiding this comment.
@deepakpanda93, could you help build and push apachehudi/hudi-ci-bundle-validation-base:flink230hive313spark359 using packaging/bundle-validation/base/build_flink230hive313spark359.sh? The contributor’s image passed Flink 2.3 bundle validation on both JDK 11 and 17. Once the official image is available, we can switch CI to it and rerun validation. Thanks!
…logMode HoodieTableSink.getChangelogMode returned the upsert mode for every input unless changelog.enabled is set. Flink 2.3 rejects a streaming INSERT into an upsert sink with a primary key when the upsert key of the query differs from the primary key, unless the statement has an ON CONFLICT clause or table.exec.sink.require-on-conflict is false (FLINK-38927, FLINK-38928). A query over an insert-only source such as VALUES or Kafka has no upsert key, so a plain INSERT INTO a Hudi table with a primary key failed at planning time on Flink 2.3.0. With the option set to false Flink 2.3.0 put a stateful SinkUpsertMaterializer in front of the Hudi writer. Return the row kinds of the requested mode without UPDATE_BEFORE, as suggested in the review. An insert-only input stays insert-only, an input with updates or deletes keeps its kinds, and changelog.enabled still returns the full mode for every input. Effect on the Flink planner: - Flink 2.3: a plain INSERT from an insert-only input plans with default settings and no materializer. Flink allows ON CONFLICT for upsert sinks only, so it now rejects the clause on a statement whose input is insert-only. - Flink 1.18 to 2.2: none. These planners add the materializer only for an input that is not insert-only, and for such an input the sink still takes the changes without UPDATE_BEFORE, as before. The Paimon and Fluss sinks do the same for tables with a primary key, and the Iceberg sink returns the requested mode as it is. TestHoodieTableSink covers the branches of getChangelogMode. TestHoodieTablePlanning plans a streaming INSERT for an insert-only input and for an input with updates.
…kstart and the validation SQL HoodieTableSink now reports insert-only for an insert-only input, so Flink 2.3 plans a plain INSERT into a Hudi table with a primary key without table.exec.sink.require-on-conflict=false. Take the option out of ITTestHoodieDataSource, ITTestDynamicBucketStreamWrite, ITTestBucketStreamWrite, HoodieFlinkQuickstart and packaging/bundle-validation/flink/insert.sql again. These five files are back to their state on master.
…until it is published (temporary) The bundle validation for flink2.3 needs the base image apachehudi/hudi-ci-bundle-validation-base:flink230hive313spark359, which is not on Docker Hub yet. Until a maintainer publishes it, ci_run.sh pulls the image built with packaging/bundle-validation/base/build_flink230hive313spark359.sh from nestdream/hudi-ci-bundle-validation-base by digest and tags it with the official name, so that the validation runs in CI. Drop this commit before merge.
| <hudi.flink.module>hudi-flink2.3.x</hudi.flink.module> | ||
| <flink.bundle.version>2.3</flink.bundle.version> | ||
| <!-- check kafka version --> | ||
| <flink.connector.kafka.version>5.0.0-2.2</flink.connector.kafka.version> |
There was a problem hiding this comment.
Can you update flink.connector.kafka.version from 5.0.0-2.2 to 5.1.0-2.3 in both the default configuration and the flink2.3 profile? The Kafka connector build for Flink 2.3 is now available on Maven Central.
There was a problem hiding this comment.
@cshuo Done, flink.connector.kafka.version is now 5.1.0-2.3 in the default properties and in the flink2.3 profile. I also removed the check kafka version note from the profile.
The Kafka connector built for Flink 2.3 is on Maven Central now. The default properties and the flink2.3 profile move to it, and the "check kafka version" note in the flink2.3 profile is dropped. The flink2.2 profile stays on 5.0.0-2.2.
Conflict in .github/workflows/bot.yml: the integration-tests job keeps flinkProfile flink2.3 and takes the Spark 3.5.10 archive from master.
Describe the issue this Pull Request addresses
Closes #20775.
Flink 2.3.0 has been on Maven Central since June 2026. Hudi has adapter modules and bundles for Flink 1.18 to 2.2, so users on Flink 2.3 have no bundle that is compiled and tested against their Flink version. This PR adds Flink 2.3 the way #19655 added Flink 2.2.
One thing needs a maintainer: the bundle validation base image for Flink 2.3.0 has to be published (end of Risk Level).
Summary and Changelog
hudi-flink2.3.xmodule and aflink2.3Maven profile based on Flink 2.3.0. The module is a copy ofhudi-flink2.2.xand only itspom.xmldiffers. The adapter code needed no change for Flink 2.3.0.flink2.2profile and the older ones stay.HoodieTableSink#getChangelogModekeeps the row kinds of the requested mode and leaves out onlyUPDATE_BEFORE.flink230hive313spark359.The first commit is the plain module copy. Commits 4 and 5 are from the first version of this PR, which set an option in tests. Commit 7 reverts them, so the three cancel out. Commit 8 is temporary (end of Risk Level).
Impact
The default Hudi Flink build and bundle now target Flink 2.3.0. Users on Flink 2.2 keep building with
-Dflink2.2. The storage format and the public APIs do not change.One Flink 2.3 change affects Hudi users. Flink 2.3 adds the
ON CONFLICTclause and the optiontable.exec.sink.require-on-conflict,trueby default (FLIP-558, FLINK-38927). A streamingINSERT INTOan upsert sink with a primary key now fails at planning time when the upsert key of the query differs from the primary key and the statement has noON CONFLICTclause. An append-only source has no upsert key andHoodieTableSinkasked for an upsert stream for every input, so Flink 2.3 rejected a plainINSERT INTO hudi_table SELECT ... FROM append_only_sourcethat runs on 2.2:With the
flink2.3profile alone, 95 of the 434 Flink integration tests fail with this error (88 inITTestHoodieDataSource, 7 inITTestBucketStreamWriteandITTestDynamicBucketStreamWrite), and so do the 4 tests ofTestHoodieFlinkQuickstart.As suggested in the review,
HoodieTableSinknow keeps the requested row kinds withoutUPDATE_BEFORE, as the Paimon and Fluss sinks do for tables with a primary key. The write path is untouched and only planning changes:INSERTfrom an append-only source plans with default settings and without aSinkMaterializer.ON CONFLICTclause on such a statement is rejected, because the sink is then not an upsert sink.UPDATE_BEFORE, and tables withchangelog.enabledget the full mode as before. An input with updates still needsON CONFLICTon Flink 2.3 when its upsert key differs from the primary key or is missing (for example a CDC source table declared without a primary key).This PR targets Flink 2.3.0. The 2.3.1 release candidate changes the
BinaryExternalSorterconstructor (FLINK-40959), which needs a separate fix in the 1.20, 2.2 and 2.3 adapters.Risk Level
Medium, as for #19655: the default Flink dependency line changes and a version-specific module is added. The sink change is one method in
HoodieTableSink. It has unit tests for the branches of the method and a planning test, and three of the four new tests fail without it.What I ran on top of master
f383424d889, on Java 17 unless noted. More checks, the cluster cases and the commands are in the collapsed blocks below.-Dflink2.3: Flink modules, examples, bundle,hudi-kafka-connectand its bundle, with checkstyle and RAThudi-flink2.3.x,hudi-flink-client,hudi-flinkandTestHoodieFlinkQuickstartIT*withoutITTestHoodieDataSource, andITTestHoodieDataSource-Dflink2.2: the sink, planning and table factory tests,TestHoodieFlinkQuickstart, 20 integration tests of streaming writes-Dflink1.20: the same 20 integration testsci_run.sh) with the base image built by the new script, OpenJDK 11 and 17The counts in rows 2 and 3 are those of the CI run of the same master commit with
flink2.2, plus the 4 new sink tests. No test setstable.exec.sink.require-on-conflictany more.After merging master
7c1fb1b5c6eand moving to Kafka Connector 5.1.0-2.3, I re-ran the build, the unit tests (55, 247, 2227 and 4 run, 0 failed, 2 skipped), both integration test filters (154 and 280 run, 0 failed, 1 skipped) and thehudi-kafka-connectbuild and tests.I also ran the bundle on a standalone Flink 2.3.0 cluster with default settings. A batch job read each table back, and row count, distinct keys, min, max and sum matched the expected values.
The
validate-bundlesjob forflink2.3needs the base imageapachehudi/hudi-ci-bundle-validation-base:flink230hive313spark359, which is not on Docker Hub yet. I built it withpackaging/bundle-validation/base/build_flink230hive313spark359.shand pushed it tonestdream/hudi-ci-bundle-validation-base:flink230hive313spark359(linux/amd64, digestsha256:d3a4584605165f03dc574be58422c90fc521cd2099a3a9b78c072ad45e10b0eb). The temporary commit (commit 8) pulls it from there by digest. Could someone with push rights publish it toapachehudi, as was done for #19655? I will then remove that commit and rerun, so that CI pulls the published tag.Cluster cases
Flink 2.3.0, default settings, no
table.exec.sinkoption.INSERTfrom an append-only source into a COPY_ON_WRITE table with a primary keySinkMaterializerin the job graphGROUP BYthe key)ON CONFLICT(not changed by this PR)ON CONFLICT DO DEDUPLICATEchangelog.enabled, plainINSERTfrom an append-only sourcedebezium-json) into COPY_ON_WRITE and MERGE_ON_READ tables, also withchangelog.enabledON CONFLICT DO DEDUPLICATE,DO NOTHINGorDO ERRORon anINSERTfrom an append-only sourcebulk_insertin batch mode into a partitioned tableMore checks
hudi-kafka-connecthudi-flink2.3.x, the sink, planning and table factory testsflink1.18toflink2.2Commands
Documentation Update
The README and the release guide are updated for Flink 2.3. The Flink pages of the website should mention that Flink 2.3 rejects an
ON CONFLICTclause on anINSERTfrom an append-only source into a Hudi table. That is a separate change.Contributor's checklist