hudi-agent commented on code in PR #19553:
URL: https://github.com/apache/hudi/pull/19553#discussion_r3735857781


##########
hudi-common/src/test/java/org/apache/hudi/common/table/read/TestIncrementalQueryAnalyzer.java:
##########
@@ -86,4 +107,209 @@ void testBuilderRequiresMetaClientAndRangeType() {
         .metaClient(mock(HoodieTableMetaClient.class))
         .build());
   }
+
+  @Test
+  void testV1LoadsArchivedTimelineOnceAndReusesIt() {
+    AnalyzerFixture fixture = analyzerFixture(
+        TimelineLayoutVersion.LAYOUT_VERSION_1,
+        Arrays.asList(instant(T3), instant(T4)),
+        Arrays.asList(instant(T1), instant(T2)));
+    when(fixture.completionTimeQueryView.isArchived(T2)).thenReturn(true);
+
+    IncrementalQueryAnalyzer.QueryContext queryContext = fixture.analyzer(T2, 
T4).analyze();
+
+    assertEquals(Arrays.asList(T2, T3, T4), queryContext.getInstantTimeList());
+    assertEquals(Collections.singletonList(T2), 
requestedTimes(queryContext.getArchivedInstants()));
+    assertEquals(Arrays.asList(T3, T4), 
requestedTimes(queryContext.getActiveInstants()));
+    assertSame(fixture.archivedCommitsTimeline, 
queryContext.getArchivedTimeline());
+    verify(fixture.metaClient, times(1)).getArchivedTimeline(T2, false);
+    verify(fixture.completionTimeQueryView, never()).getInstantTimes(
+        any(HoodieTimeline.class), any(), any(), 
any(InstantRange.RangeType.class));
+  }
+
+  @Test
+  void testV1EndOnlyLoadsArchiveOnceAndSelectsLastEligibleInstant() {
+    AnalyzerFixture fixture = analyzerFixture(
+        TimelineLayoutVersion.LAYOUT_VERSION_1,
+        Arrays.asList(instant(T3), instant(T4)),
+        Arrays.asList(instant(T1), instant(T2)));
+
+    IncrementalQueryAnalyzer.QueryContext queryContext = 
fixture.analyzer(null, T2).analyze();
+
+    assertEquals(Collections.singletonList(T2), 
queryContext.getInstantTimeList());
+    assertEquals(Collections.singletonList(T2), 
requestedTimes(queryContext.getArchivedInstants()));
+    assertTrue(queryContext.getActiveInstants().isEmpty());
+    assertSame(fixture.archivedCommitsTimeline, 
queryContext.getArchivedTimeline());
+    verify(fixture.metaClient, times(1)).getArchivedTimeline("", false);
+  }
+
+  @Test
+  void testV1ActiveOnlyAndSnapshotRangesDoNotLoadArchive() {

Review Comment:
   🤖 nit: this test covers two distinct cases (active-only range and 
earliest-snapshot range) in one method, which makes it harder to pinpoint which 
scenario caused a failure. Could you split it into 
`testV1ActiveOnlyRangeDoesNotLoadArchive` and 
`testV1EarliestSnapshotDoesNotLoadArchive`?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



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