Davis-Zhang-Onehouse commented on code in PR #12688:
URL: https://github.com/apache/hudi/pull/12688#discussion_r1930891856


##########
hudi-common/src/test/java/org/apache/hudi/common/table/checkpoint/TestCheckpointUtils.java:
##########
@@ -168,7 +173,39 @@ public void testConvertCheckpointWithInitTimestamp() {
     assertEquals(HoodieTimeline.INIT_INSTANT_TS, 
translated.getCheckpointKey());
 
     checkpoint = new StreamerCheckpointV2(instantTime);
-    translated = 
CheckpointUtils.convertToCheckpointV2ForCommitTime(checkpoint, metaClient);
+    translated = 
CheckpointUtils.convertToCheckpointV2ForCommitTime(checkpoint, metaClient, 
BLOCK);
     assertEquals(HoodieTimeline.INIT_INSTANT_TS, 
translated.getCheckpointKey());
   }
+
+  @Test
+  public void testConvertCheckpointWithUseTransitionTime() {
+    String instantTime = "20231127010101";
+    String completionTime = "20231127020102";
+
+    // Mock active timeline
+    HoodieInstant instant = new HoodieInstant(HoodieInstant.State.COMPLETED, 
"commit", instantTime, completionTime, 
InstantComparatorV1.REQUESTED_TIME_BASED_COMPARATOR);
+    when(activeTimeline.getInstantsAsStream()).thenReturn(Stream.of(instant));
+
+    Checkpoint checkpoint = new StreamerCheckpointV1(completionTime);
+    StreamerCheckpointV2 translatedCheckpoint = 
CheckpointUtils.convertToCheckpointV2ForCommitTime(checkpoint, metaClient, 
USE_TRANSITION_TIME);
+
+    assertEquals(completionTime, translatedCheckpoint.getCheckpointKey());
+  }
+
+  @ParameterizedTest
+  @CsvSource({
+      // version, sourceClassName, expectedResult
+      // Version >= 8 with allowed sources should return true
+      "8, org.apache.hudi.utilities.sources.TestSource, true",
+      "9, org.apache.hudi.utilities.sources.AnotherSource, true",
+      // Version < 8 should return false regardless of source
+      "7, org.apache.hudi.utilities.sources.TestSource, false",
+      "6, org.apache.hudi.utilities.sources.AnotherSource, false",
+      // Disallowed sources should return false even with version >= 8
+      "8, org.apache.hudi.utilities.sources.S3EventsHoodieIncrSource, false",
+      "8, org.apache.hudi.utilities.sources.GcsEventsHoodieIncrSource, false"

Review Comment:
   done



-- 
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