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/01/05 05:16:30 UTC

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

xushiyan commented on a change in pull request #4489:
URL: https://github.com/apache/hudi/pull/4489#discussion_r778551692



##########
File path: hudi-common/src/main/java/org/apache/hudi/metadata/HoodieTableMetadataUtil.java
##########
@@ -109,15 +111,31 @@ public static void deleteMetadataTable(String basePath, HoodieEngineContext cont
             : hoodieWriteStat.getTotalWriteBytes();
         newFiles.put(filename, totalWriteBytes);
       });
+
       // New files added to a partition
-      HoodieRecord record = HoodieMetadataPayload.createPartitionFilesRecord(
-          partition, Option.of(newFiles), Option.empty());
-      records.add(record);
+      if (!newFiles.isEmpty()) {
+        HoodieRecord record = HoodieMetadataPayload.createPartitionFilesRecord(
+                partition, Option.of(newFiles), Option.empty());
+        records.add(record);
+      }
     });
 
-    // New partitions created
-    HoodieRecord record = HoodieMetadataPayload.createPartitionListRecord(new ArrayList<>(allPartitions));
-    records.add(record);
+    // Add delete partition's record
+    if (commitMetadata instanceof HoodieReplaceCommitMetadata
+            && WriteOperationType.DELETE_PARTITION.equals(commitMetadata.getOperationType())) {

Review comment:
       would it be better to extract these logic to a common util method to make it explicit about this check? say `isDeletePartition()`. Recall somewhere else also checking this 




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