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 2022/02/17 02:00:33 UTC

[GitHub] [hudi] XuQianJin-Stars commented on a change in pull request #4489: [HUDI-3135] Fix Delete partitions with metadata table and fix show partitions in spark sql

XuQianJin-Stars commented on a change in pull request #4489:
URL: https://github.com/apache/hudi/pull/4489#discussion_r808605408



##########
File path: hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/clean/CleanPlanner.java
##########
@@ -432,4 +458,47 @@ private boolean isFileSliceNeededForPendingCompaction(FileSlice fileSlice) {
   private boolean isFileGroupInPendingCompaction(HoodieFileGroup fg) {
     return fgIdToPendingCompactionOperations.containsKey(fg.getFileGroupId());
   }
+
+  public boolean isDropPartition(Option<HoodieInstant> instantToRetain) {
+    try {
+      if (instantToRetain.isPresent() && HoodieTimeline.REPLACE_COMMIT_ACTION.equals(instantToRetain.get().getAction())) {
+        HoodieReplaceCommitMetadata replaceCommitMetadata = HoodieReplaceCommitMetadata.fromBytes(
+            hoodieTable.getActiveTimeline().getInstantDetails(instantToRetain.get()).get(), HoodieReplaceCommitMetadata.class);
+
+        if (replaceCommitMetadata != null
+            && WriteOperationType.DELETE_PARTITION.equals(replaceCommitMetadata.getOperationType())) {
+          return true;
+        }
+      }
+    } catch (Exception e) {
+      throw new HoodieException("Failed to get commit metadata", e);
+    }
+    return false;
+  }
+
+  public List<String> getDropPartitions(Option<HoodieInstant> instantToRetain) {
+    try {
+      if (!instantToRetain.isPresent()) {
+        LOG.info("No earliest commit to retain. No need to scan partitions !!");
+        return Collections.emptyList();
+      }
+
+      if (HoodieTimeline.REPLACE_COMMIT_ACTION.equals(instantToRetain.get().getAction())) {

Review comment:
       well, I see what you mean, I'll check again.




-- 
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: commits-unsubscribe@hudi.apache.org

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