Skip to content

[python] Implement partition expiration for pypaimon#7918

Open
JunRuiLee wants to merge 1 commit into
apache:masterfrom
JunRuiLee:pypaimon-expire-partitions
Open

[python] Implement partition expiration for pypaimon#7918
JunRuiLee wants to merge 1 commit into
apache:masterfrom
JunRuiLee:pypaimon-expire-partitions

Conversation

@JunRuiLee
Copy link
Copy Markdown
Contributor

Purpose

Add pypaimon support for expiring partitions based on table options and CLI overrides, matching the Java partition expiration behavior for values-time and update-time strategies.

This includes:

  • Partition expiration orchestration for FileStoreTable.
  • Partition entry discovery from manifest metadata.
  • Time extraction from partition values.
  • Java DateTimeFormatter-style timestamp formatter support.
  • table expire-partitions CLI command.
  • Partition expiration options in Python CoreOptions.
  • Null partition handling via partition.default-name.
  • Default partition.expiration-max-num=100.

Tests

Added paimon-python/pypaimon/tests/partition_expire_test.py covering:

  • Extracting partition time from simple date and timestamp values.
  • Extracting time with timestamp patterns across multiple partition fields.
  • Java formatter conversion cases like yyyyMMdd.
  • Selecting expired partitions with values-time.
  • Selecting expired partitions with update-time.
  • Skipping unparseable partition values.
  • Respecting expiration check interval.
  • Respecting max expire count.
  • Empty partition lists.
  • Unconfigured expiration.
  • Non-partitioned tables.
  • Duration parsing for days, hours, minutes, seconds, milliseconds, and combined durations.

Add automatic partition expiration support with two strategies:
- values-time: parse partition field values as timestamps
- update-time: use last file creation time from manifests

New module pypaimon/partition/ with:
- PartitionTimeExtractor: extracts datetime from partition values
- PartitionExpireStrategy: abstract base + two implementations
- PartitionExpire: orchestration class reading manifests and dropping partitions

Also adds:
- Table-level API: table.expire_partitions()
- CLI command: paimon table expire-partitions
- Partition expiration options in CoreOptions
- Unit tests (28 tests)
@JunRuiLee JunRuiLee force-pushed the pypaimon-expire-partitions branch from a74bf8c to 30cba0e Compare May 20, 2026 11:02
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.

1 participant