[python] Add create_tag_from_timestamp to FileStoreTable#7946
[python] Add create_tag_from_timestamp to FileStoreTable#7946JunRuiLee wants to merge 2 commits into
Conversation
JingsongLi
left a comment
There was a problem hiding this comment.
Clean and concise implementation. A couple of minor points:
-
Consistency with Java API: In the Java Paimon
TagManager,create_tag_from_timestamptypically usesSnapshotManager.earlierOrEqualTimeMills()which returns aSnapshotornull. Your implementation follows the same pattern. LGTM. -
Error message: The ValueError message says "earlier than or equal to" but the method name says
earlier_or_equal_time_mills. Consider aligning: either say "at or before" or "earlier than or equal to" — just pick one style. -
Suggest adding a test: Even though this is a thin wrapper, a unit test that creates a couple of snapshots with known timestamps and then calls
create_tag_from_timestampwould protect against regressions (e.g., ifearlier_or_equal_time_millssemantics change).
Otherwise LGTM — this is a useful addition for time-based tag creation from the Python API.
Allow creating a tag from the latest snapshot at or before a given timestamp (in milliseconds), aligning with Java's CreateTagFromTimestampProcedure behavior.
- Align error message wording to "at or before" - Add unit tests for create_tag_from_timestamp
b0ec6c2 to
8f72e99
Compare
JunRuiLee
left a comment
There was a problem hiding this comment.
@JingsongLi Thanks for the review!
-
Consistency with Java API: Thanks, glad the pattern aligns.
-
Error message: Updated to use "at or before" consistently (matching the docstring).
-
Test: Added
test_create_tag_from_timestamp(creates 2 snapshots, tags from a future timestamp, asserts correct snapshot) andtest_create_tag_from_timestamp_no_snapshot_raises(timestamp 0, asserts ValueError).
Summary
create_tag_from_timestamp(tag_name, timestamp_millis, ignore_if_exists)method toFileStoreTableSnapshotManager.earlier_or_equal_time_mills()binary search to find the latest snapshot at or before the given timestampCreateTagFromTimestampProcedurebehaviorMotivation
PyPaimon currently supports creating tags from a specific snapshot ID or the latest snapshot, but lacks the ability to create a tag from a timestamp — a feature available in the Java API via
CreateTagFromTimestampProcedure. This is useful for batch workflows that need to pin a snapshot based on wall-clock time.Tests
earlier_or_equal_time_millsis already covered bySnapshotManagertests)