You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2021/05/06 15:18:42 UTC

[GitHub] [hudi] vinothchandar commented on a change in pull request #2809: [HUDI-1789] Support reading older snapshots

vinothchandar commented on a change in pull request #2809:
URL: https://github.com/apache/hudi/pull/2809#discussion_r627514500



##########
File path: hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/HoodieHiveUtils.java
##########
@@ -122,19 +135,44 @@ public static Path getNthParent(Path path, int n) {
     return result;
   }
 
+  /**
+   * Depending on the configs hoodie.%s.consume.pending.commits and hoodie.%s.consume.commit of job
+   *
+   * (hoodie.<tableName>.consume.pending.commits, hoodie.<tableName>.consume.commit) ->
+   *      (true, validCommit)       -> returns activeTimeline filtered until validCommit
+   *      (true, InValidCommit)     -> Raises HoodieIOException
+   *      (true, notSet)            -> Raises HoodieIOException
+   *      (false, validCommit)      -> returns compeltedTimeline filtered until validCommit
+   *      (false, InValidCommit)    -> Raises HoodieIOException
+   *      (false or notSet, notSet) -> returns completedTimeline unfiltered
+   *
+   *      validCommit is one which exists in the timeline being checked and vice versa
+   *
+   * @param tableName
+   * @param job
+   * @param metaClient
+   * @return
+   */
   public static HoodieTimeline getTableTimeline(final String tableName, final JobConf job, final HoodieTableMetaClient metaClient) {
+    HoodieTimeline timeline = metaClient.getActiveTimeline().getCommitsTimeline();
+
     boolean includePendingCommits = job.getBoolean(String.format(HOODIE_CONSUME_PENDING_COMMITS, tableName), false);
-    if (includePendingCommits) {
-      HoodieTimeline timeline = metaClient.getActiveTimeline().getCommitsTimeline();
-      String maxCommit = job.get(String.format(HOODIE_CONSUME_COMMIT, tableName));
-      if (maxCommit == null || !timeline.containsInstant(maxCommit)) {
-        LOG.info("Timestamp configured for validation: " + maxCommit + " commits timeline:" + timeline + " table: " + tableName);
-        throw new HoodieIOException("Valid timestamp is required for " + HOODIE_CONSUME_COMMIT + " in validate mode");
+    String maxCommit = job.get(String.format(HOODIE_CONSUME_COMMIT, tableName));
+
+    if (!includePendingCommits) {

Review comment:
       can this block be simplified as 
   
   ```
   if (!includePendingCommits && maxCommit == null) {
     return timeline.filterCompletedInstants();
   }
   
   ```
   
   




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org