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


##########
hudi-common/src/main/java/org/apache/hudi/common/table/read/IncrementalQueryAnalyzer.java:
##########
@@ -188,10 +188,12 @@ public QueryContext analyze() {
         }
       }
       if (!archivedInstantTimes.isEmpty()) {
-        archivedReadTimeline = getArchivedReadTimeline(metaClient, 
archivedInstantTimes.get(0));
+        archivedReadTimeline = getArchivedReadTimeline(metaClient, 
archivedInstantTimes.stream().min(String::compareTo).get());
         archivedInstants = 
archivedReadTimeline.getInstantsAsStream().filter(instant -> 
instantTimeSet.contains(instant.requestedTime())).collect(Collectors.toList());
       }
-      List<String> instants = Stream.concat(archivedInstants.stream(), 
activeInstants.stream()).map(HoodieInstant::requestedTime).collect(Collectors.toList());
+      // archived and active instants can interleave (see 
#splitInstantByActiveness), so order them by instant time.
+      List<String> instants = Stream.concat(archivedInstants.stream(), 
activeInstants.stream()).map(HoodieInstant::requestedTime)
+          .sorted().collect(Collectors.toList());

Review Comment:
   🤖 non-blocking: `instants` is sorted now, but 
`QueryContext.getMaxCompletionTime()`, `getInstants()` and Flink's 
`mergeList(archived, active)` still assume archived instants come first. For 
example, a Flink incremental read with start before C1 and end before C7 gets 
active = [C1], so `getMaxCompletionTime()` returns C1's completion time, and 
the full-scan branch's `getLatestMergedFileSlicesBeforeOrOn` then drops the 
C2–C6 file slices. Could `getMaxCompletionTime()` fall back to the active 
timeline's latest completion time when archived instants completed after the 
active ones, and could the archived/active lists also be ordered by instant 
time for downstream readers?
   
   <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