yihua commented on code in PR #10923:
URL: https://github.com/apache/hudi/pull/10923#discussion_r1538385249


##########
hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieDefaultTimeline.java:
##########
@@ -512,16 +512,20 @@ public Option<HoodieInstant> getFirstNonSavepointCommit() 
{
   }
 
   @Override
-  public Option<HoodieInstant> getLastClusterCommit() {
-    return  Option.fromJavaOptional(getCommitsTimeline().filter(s -> 
s.getAction().equalsIgnoreCase(HoodieTimeline.REPLACE_COMMIT_ACTION))
+  public Option<HoodieInstant> getLastCompleteOrPendingClusteringInstant() {
+    return Option.fromJavaOptional(getCommitsTimeline().filter(s -> 
s.getAction().equalsIgnoreCase(HoodieTimeline.REPLACE_COMMIT_ACTION))
         .getReverseOrderedInstants()
         .filter(i -> {
-          try {
-            HoodieCommitMetadata metadata = TimelineUtils.getCommitMetadata(i, 
this);
-            return 
metadata.getOperationType().equals(WriteOperationType.CLUSTER);
-          } catch (IOException e) {
-            LOG.warn("Unable to read commit metadata for " + i + " due to " + 
e.getMessage());
-            return false;
+          if (i.isCompleted()) {
+            try {
+              HoodieCommitMetadata metadata = 
TimelineUtils.getCommitMetadata(i, this);
+              return 
metadata.getOperationType().equals(WriteOperationType.CLUSTER);
+            } catch (IOException e) {
+              LOG.warn("Unable to read commit metadata for " + i + " due to " 
+ e.getMessage());
+              return false;
+            }
+          } else {
+            return ClusteringUtils.isPendingClusteringInstant(this, i);

Review Comment:
   Good call.  Addressed.



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