yihua commented on a change in pull request #4556:
URL: https://github.com/apache/hudi/pull/4556#discussion_r791314687



##########
File path: 
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/HoodieFileInputFormatBase.java
##########
@@ -187,13 +286,28 @@ private static FileStatus 
getFileStatusUnchecked(Option<HoodieBaseFile> baseFile
               .map(fileSlice -> {
                 Option<HoodieBaseFile> baseFileOpt = fileSlice.getBaseFile();
                 Option<HoodieLogFile> latestLogFileOpt = 
fileSlice.getLatestLogFile();
-                if (baseFileOpt.isPresent()) {
-                  return getFileStatusUnchecked(baseFileOpt);
-                } else if (includeLogFilesForSnapShotView() && 
latestLogFileOpt.isPresent()) {
-                  return 
createRealtimeFileStatusUnchecked(latestLogFileOpt.get(), 
fileSlice.getLogFiles());
+                Stream<HoodieLogFile> logFiles = fileSlice.getLogFiles();
+
+                Option<HoodieInstant> latestCompletedInstantOpt =
+                    fromScala(fileIndex.latestCompletedInstant());
+
+                // Check if we're reading a MOR table
+                if (includeLogFilesForSnapshotView()) {
+                  if (baseFileOpt.isPresent()) {
+                    return 
createRealtimeFileStatusUnchecked(baseFileOpt.get(), logFiles, 
latestCompletedInstantOpt, tableMetaClient);
+                  } else if (latestLogFileOpt.isPresent()) {
+                    return 
createRealtimeFileStatusUnchecked(latestLogFileOpt.get(), logFiles, 
latestCompletedInstantOpt, tableMetaClient);
+                  } else {
+                    throw new IllegalStateException("Invalid state: either 
base-file or log-file has to be present");
+                  }
                 } else {
-                  throw new IllegalStateException("Invalid state: either 
base-file or log-file should be present");
+                  if (baseFileOpt.isPresent()) {
+                    return getFileStatusUnchecked(baseFileOpt.get());
+                  } else {
+                    throw new IllegalStateException("Invalid state: base-file 
has to be present");
+                  }
                 }

Review comment:
       It looks like the logic is changed here to cover broader cases, 
especially when both base file and log files exist.  Basically, if base file 
exists, log files are ignored before.  However, for Snapshot mode, should log 
files be ignored by default?  Or do you intend to use this method 
`listStatusForSnapshotMode()` broadly for different query mode (renaming it if 
true)?




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