Skip to content

[core] Support retaining the latest expired partition - #10766

Merged
JingsongLi merged 2 commits into
apache:masterfrom
tzphh:feature/partition-expiration-retain-latest
Oct 27, 2026
Merged

JingsongLi merged 2 commits into
apache:masterfrom
tzphh:feature/partition-expiration-retain-latest

Conversation

@tzphh

@tzphh tzphh commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Purpose

Fix #10715.
Add partition.expiration-retain-latest to retain the latest partition when all partitions are eligible for expiration, keeping data available when no new data arrives.

The option defaults to false and supports the built-in values-time and update-time strategies on normal tables.

Tests

73 tests passed across PartitionExpireTest,PartitionExpireTableTest, and CoreOptionsTest.

Coverage includes repeated expiration, replacement after a new partition is
committed, expiration limits and batching, stable timestamp ties, and
Metastore partition deletion.

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

LGTM
I traced both built-in expiration strategies through partition-entry aggregation, max-count limiting, batching, metastore deletion, and repeated expiration runs. Retaining the candidate before limits are applied preserves the latest partition across repeated runs, while a newly committed later partition correctly releases the old one. The deterministic tie-breaker and malformed-value behavior also look appropriate. The added tests cover the important lifecycle and boundary cases.

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

The fallback-data use case is supported, and the targeted options/partition-expiration reactor passes with normal Maven checks. I also traced repeated expiration, limits/batches, committed replacement partitions, metastore deletion, malformed values and default compatibility.

An additional real-catalog test finds that the Flink age-based expiration action bypasses the new protection: core expiration retains the one row; executing the action with retain-latest explicitly true leaves zero rows. The inline comment describes the missing option propagation. The action was compiled from this head against the head core/API; its inherited catalog/action dependencies are byte-identical to the base.

For rollout, all expiration owners must be upgraded/restarted before enabling the safeguard; older owners ignore the option. Pause expiration before rolling those owners back. There is no new on-disk format.

.withDescription("The default deleted num of partition expiration.");

public static final ConfigOption<Boolean> PARTITION_EXPIRATION_RETAIN_LATEST =
key("partition.expiration-retain-latest")

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 the safeguard into the Flink expiration action

The supported ExpirePartitionsAction copies table configuration into its table, but constructs PartitionExpireStrategy from a separate map containing only strategy/formatter/pattern. Consequently the new strategy constructors always see retain-latest=false there, even if it is persisted on the table and explicitly supplied through the action's table-conf map.

I reproduced this with a real filesystem table containing only dt=20010101, TTL 1 d, formatter yyyyMMdd, and retain-latest=true. table.store().newPartitionExpire(...).expire(...) leaves its one row; the actual Flink ExpirePartitionsAction.executeLocally() with the same safeguard explicitly true deletes it and leaves an empty table. This is age-based expiration, not the explicit DROP/TRUNCATE exception documented below.

Please build the action's strategy options from the table/configured options before applying its CLI overrides, or explicitly propagate this option, and add an action-level regression that keeps the sole expired partition.

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.

Thanks for catching this! Fixed by propagating partition.expiration-retain-latest from the merged table options to the action's expiration strategy. Added action-level regression tests covering persisted settings, --table_conf overrides, and repeated expiration of the sole expired partition.

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

+1

@JingsongLi
JingsongLi merged commit ba7e199 into apache:master Oct 27, 2026
18 checks passed
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.

[Feature] Retain the latest partition when all partitions have expired

3 participants