Skip to content

[flink] Support Paimon primary-key promotion with BulkLoad - #5400

Open
luoyuxia wants to merge 8 commits into
apache:mainfrom
luoyuxia:fip-25-paimon-bulkload-promotion
Open

luoyuxia wants to merge 8 commits into
apache:mainfrom
luoyuxia:fip-25-paimon-bulkload-promotion

Conversation

@luoyuxia

@luoyuxia luoyuxia commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Linked issue: Part of #4846.

Enable Fluss on an existing Paimon primary-key table with historical data. Initialize Fluss KV state from one fixed Paimon snapshot, then register that snapshot and enable lake reads after BulkLoad commits.

Builds on the Java BulkLoad SDK merged in #5399 and the import validation and bucket-key compatibility changes merged in #5403.

Brief change log

  • Add the load_lake_data_to_fluss batch action and invoke it from sys.enable_fluss_on_lake_table for primary-key tables with an existing snapshot. The procedure waits in synchronous DML mode and returns a JobID in asynchronous mode.
  • Inherit Flink's configured load parallelism, including when fewer task slots than source buckets are available. For an empty source without a committed snapshot, the action still submits a batch job to enable lake access, without creating a BulkLoad transaction or registering a snapshot.
  • Load the source partitions retained by the target's automatic-partition policy, or all source partitions for manually partitioned tables. Resume with the transaction's original partition scope and skip buckets whose snapshots have already committed.
  • Support task restarts and explicit resubmission with a caller-persisted source snapshot ID and BulkLoad ID. The caller must preserve the original source snapshot and stop old writers before resubmitting.
  • Reject source splits whose actual physical bucket count differs from the target bucket count recorded by Begin before submitting the load job, including old partitions after bucket expansion or shrinkage.
  • Return original partition names in progress responses so retries can replay Begin with the complete original target set after retention deletes partitions. Preserve physical partition IDs so same-name replacements are not imported.
  • Use Table.newBulkLoad() throughout submission, workers and finalization. The JobGraph carries transaction identity, original partition names and expected bucket boundaries; workers retrieve the original context through idempotent Begin.
  • On task replay, skip all bucket work when the transaction is already committed, including withdrawn buckets with no individual commit record, so finalization can recover after a full job restart.
  • Finalize through one shared connection: replay the idempotent transaction commit, register zero WAL boundaries, then enable lake reads. The server checks bucket completeness. Reuse the existing registered snapshot when re-enabling a table, and expose bucket progress metrics and logs.
  • Retry Begin while target metadata becomes visible, using a three-minute retry window and a three-second delay. Each request uses the configured client request timeout; an in-flight request can finish after the retry window. Support checks remain in creation, the coordinator and the SDK writer.
  • Pass client.fs.* configuration from the Flink catalog to load workers and finalization, and retain Flink 1.18 procedure compatibility.

Tests

  • Targeted runs passed 78 cases: 10 action unit cases, 52 Paimon catalog cases, 9 promotion/recovery cases, 2 data-backed import rejection cases, 3 Flink 1.20 SQL call signatures and 2 Flink 1.18 positional signatures. The Flink 1.18 named-argument input is skipped as expected.
  • Promotion coverage includes the manual-partition CLI path without either ID using one slot for two buckets, automatic retention with the time key second, a snapshot with no retained partitions, and a separate source with no snapshot.
  • Recovery covers an unchanged previously committed KV snapshot, loading the remaining bucket within the original partition scope, explicit resubmission after transaction commit, and replaying the original JobGraph after registration failure while leaving a replacement partition untouched.
  • The 4-to-8 expansion fixture uses one key whose old bucket remains in range but differs from the target routing. Both import rejection fixtures have committed source snapshots and verify no Fluss metadata is created.
  • Spotless, Checkstyle and license validation passed. Earlier focused checks also covered snapshot committing, catalog filesystem options and split metadata/serialization.

The full repository test suite was not rerun.

API and Format

Adds a Flink action and a catalog constructor accepting filesystem options. commitLakeSnapshot accepts a complete explicit offset map, including an empty map for snapshots without Fluss offsets. Adds LakeSplit.totalBuckets() as a default method returning a nullable Integer (null when unavailable); Paimon exposes the actual physical bucket count from DataSplit. The procedure can now submit a load job for existing primary-key data. Extends BulkLoadInfo.TargetProgress with the original partition name and adds optional partition_name field 6 to the existing progress response. No new RPC method, persisted transaction format or snapshot format. Resuming a partitioned load requires a coordinator that returns the original target partition names, including names of deleted targets.

Documentation

Action and factory Javadocs describe submission arguments and the caller's responsibility for preserving the source snapshot when reusing a BulkLoad ID. Implements the primary-key data initialization portion of FIP-25; broader user documentation remains a follow-up.

@luoyuxia
luoyuxia marked this pull request as ready for review November 27, 2026 06:49
@luoyuxia
luoyuxia force-pushed the fip-25-paimon-bulkload-promotion branch 2 times, most recently from eebbaca to f7efeab Compare November 27, 2026 09:51
required int64 allocated_bucket_count = 3;
required int64 committed_bucket_count = 4;
required bool withdrawn = 5;
optional string partition_name = 6;

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.

partition_name is needed to recover a load after retention deletes one of its target partitions. Replaying Begin requires the complete original partition-name set, while the current partition list can no longer resolve a deleted target's ID to its name. This field returns the name already frozen in the transaction; partition_id remains the target identity, so a same-name replacement is not imported. The field is optional and does not change the persisted transaction format.

@luoyuxia

Copy link
Copy Markdown
Contributor Author

cc @wuchong @platinumhamburg

@luoyuxia
luoyuxia force-pushed the fip-25-paimon-bulkload-promotion branch from 1816605 to 623b716 Compare November 27, 2026 11:48
@luoyuxia
luoyuxia force-pushed the fip-25-paimon-bulkload-promotion branch from 623b716 to ecdf180 Compare November 27, 2026 13:20
luoyuxia and others added 7 commits November 27, 2026 22:32
Initialize Fluss KV state from a fixed Paimon snapshot before registering
recovery offsets and enabling lake reads. Reuse committed buckets and frozen
partition targets during recovery, and reject unsupported primary-key targets
before creating Fluss metadata.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 1388/1388
AI-Contributed/UT: 1499/1499
Keep coverage reporting while excluding the load action package and its
nested classes from the per-class coverage threshold.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 1/1
AI-Contributed/UT: 0/0
Expose each Paimon split's physical bucket count and validate it against
the frozen target before submitting any import tasks. Bucket IDs alone
cannot detect old partitions after a source table expands its buckets.

Cover expansion and shrinkage with real Paimon partitions, including keys
whose source and target routing differs, and verify no bucket commits or
lake initialization on rejection.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 55/55
AI-Contributed/UT: 99/99
Return original target names in progress responses and replay Begin with
the complete frozen scope after partition retention deletes a target.
Keep original physical IDs so replacement partitions remain isolated.

Skip bucket writers on task replay once the transaction has committed.
Withdrawn targets may have no bucket commit record, and finalization
must still be able to recover after a full job restart.

Cover running and committed transactions, same-name replacements, and
registration failure followed by replay of the original JobGraph.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 59/59
AI-Contributed/UT: 181/181
Use Table.newBulkLoad for transaction operations and bucket writers.
Keep handles, original partition names and expected buckets in the
JobGraph; retrieve frozen SDK contexts through idempotent Begin on
worker attempts instead of serializing SDK implementation objects.

Preserve committed-transaction replay and close the table resources
owned by worker connections and integration fixtures.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 116/116
AI-Contributed/UT: 58/58
Synchronize the checked-in Rust bindings with partition_name in the
canonical progress response using crates/fluss/regen.sh.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 4/4
AI-Contributed/UT: 0/0
Compare resolved Paimon bucket keys and reject unknown or mismatched
physical bucket layouts. Register complete lake snapshot offset maps and
use the original transaction targets when recovering after deletion.

Handle empty sources through a normal load job, inherit Flink execution
parallelism, and group the action under the bulkload package. Simplify
partition planning and use the configured timeout for Begin requests.

Cover multi-column partition enablement, empty-source initialization,
inherited parallelism and recovery after target deletion.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 2026/2038
AI-Contributed/UT: 704/704
@luoyuxia
luoyuxia force-pushed the fip-25-paimon-bulkload-promotion branch from ecdf180 to 3f750dc Compare November 27, 2026 14:35
Use the server's idempotent commit and completeness checks directly.
Share one connection across transaction commit, snapshot registration
and lake enablement. Extract bucket initialization and split reading,
and clarify action errors and helper names.

Consolidate CLI, partition selection and recovery fixtures. Keep Schema
fixtures with one TableSchema conversion helper, validate imports from
data-backed sources, and skip only named procedure inputs on Flink 1.18.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 162/162
AI-Contributed/UT: 1380/1380
@luoyuxia

Copy link
Copy Markdown
Contributor Author

@platinumhamburg Thanks for your review. I have addressed your comment

@wuchong wuchong left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

Feel free to merge it when @platinumhamburg 's comments are addressed.

@wuchong

wuchong commented Nov 27, 2026

Copy link
Copy Markdown
Member

@luoyuxia Btw, please remember to create a documentation issue for the flink action and how to use.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants