taoran92 commented on code in PR #11302:
URL: https://github.com/apache/paimon/pull/11302#discussion_r4645222395


##########
paimon-core/src/main/java/org/apache/paimon/tag/TagAutoCreation.java:
##########
@@ -132,30 +150,118 @@ public boolean forceCreatingSnapshot() {
         return false;
     }
 
+    /** Validate a newly supplied watermark before it can advance the snapshot 
watermark. */
+    public static void validateWatermark(
+            CoreOptions options,
+            long watermark,
+            SnapshotManager snapshotManager,
+            @Nullable Snapshot latestSnapshot,
+            @Nullable TagAutoCreation creation) {
+        if (watermark == Long.MIN_VALUE
+                || options.tagCreationMode() != 
CoreOptions.TagCreationMode.WATERMARK) {
+            return;
+        }
+        ZoneId zone = ZoneId.of(options.sinkWatermarkTimeZone());
+        LocalDateTime time = 
LocalDateTime.ofInstant(Instant.ofEpochMilli(watermark), zone);
+        TagPeriodHandler tagPeriodHandler = TagPeriodHandler.create(options);
+        Duration delay = options.tagCreationDelay();
+        try {
+            
tagPeriodHandler.timeToTag(tagPeriodHandler.normalizeToPreviousTag(time));
+            if (latestSnapshot != null && !delay.isZero()) {
+                tagPeriodHandler.timeToTag(
+                        
tagPeriodHandler.normalizeToPreviousTag(time.minus(delay)));
+            }
+        } catch (DateTimeException e) {
+            DateTimeException cause = e;
+            if (latestSnapshot != null) {
+                if (creation == null) {
+                    if (options.writeOnly()) {
+                        // A dedicated creator can remember tags that have 
already expired.
+                        return;

Review Comment:
   thanks for reviewing, fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to