You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@amoro.apache.org by ta...@apache.org on 2025/07/28 02:08:32 UTC

(amoro) branch master updated: Fix continually creating unused keep_file when committing for an unpartitioned mixed_hive table optimization (#3690)

This is an automated email from the ASF dual-hosted git repository.

taowang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/amoro.git


The following commit(s) were added to refs/heads/master by this push:
     new 9dfc0e0f0 Fix continually creating unused keep_file when committing for an unpartitioned mixed_hive table optimization (#3690)
9dfc0e0f0 is described below

commit 9dfc0e0f04b49d51f9c6f0ed42578de454fc2faa
Author: Nico CHen <46...@users.noreply.github.com>
AuthorDate: Mon Jul 28 10:08:28 2025 +0800

    Fix continually creating unused keep_file when committing for an unpartitioned mixed_hive table optimization (#3690)
    
    [AMORO-3684]fix continually creating unused keep_file when committing for an unpartitioned mixed_hive table optimization.
---
 .../org/apache/amoro/hive/op/UpdateHiveFiles.java    | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/amoro-format-mixed/amoro-mixed-hive/src/main/java/org/apache/amoro/hive/op/UpdateHiveFiles.java b/amoro-format-mixed/amoro-mixed-hive/src/main/java/org/apache/amoro/hive/op/UpdateHiveFiles.java
index e915ebc88..9e6e438a7 100644
--- a/amoro-format-mixed/amoro-mixed-hive/src/main/java/org/apache/amoro/hive/op/UpdateHiveFiles.java
+++ b/amoro-format-mixed/amoro-mixed-hive/src/main/java/org/apache/amoro/hive/op/UpdateHiveFiles.java
@@ -152,8 +152,16 @@ public abstract class UpdateHiveFiles<T extends SnapshotUpdate<T>> implements Sn
     this.addFiles.addAll(committedDataFiles);
     postHiveDataCommitted(this.addFiles);
 
+    // if no DataFiles to add or delete in Hive location, only commit to iceberg
+    boolean noHiveDataFilesChanged =
+        CollectionUtils.isEmpty(addFiles)
+            && CollectionUtils.isEmpty(deleteFiles)
+            && expr != Expressions.alwaysTrue();
+
     if (table.spec().isUnpartitioned()) {
-      generateUnpartitionTableLocation();
+      if (!noHiveDataFilesChanged) {
+        generateUnpartitionTableLocation();
+      }
     } else {
       this.partitionToDelete = getDeletePartition();
       this.partitionToCreate = getCreatePartition(this.partitionToDelete);
@@ -162,11 +170,6 @@ public abstract class UpdateHiveFiles<T extends SnapshotUpdate<T>> implements Sn
     if (checkOrphanFiles) {
       checkPartitionedOrphanFilesAndDelete(table.spec().isUnpartitioned());
     }
-    // if no DataFiles to add or delete in Hive location, only commit to iceberg
-    boolean noHiveDataFilesChanged =
-        CollectionUtils.isEmpty(addFiles)
-            && CollectionUtils.isEmpty(deleteFiles)
-            && expr != Expressions.alwaysTrue();
 
     delegate.commit();
     if (!noHiveDataFilesChanged) {
@@ -353,7 +356,10 @@ public abstract class UpdateHiveFiles<T extends SnapshotUpdate<T>> implements Sn
   private void checkPartitionedOrphanFilesAndDelete(boolean isUnPartitioned) {
     List<String> partitionsToCheck = Lists.newArrayList();
     if (isUnPartitioned) {
-      partitionsToCheck.add(this.unpartitionTableLocation);
+      // location is not null for an unpatitioned table is valid and it should be clean
+      if (this.unpartitionTableLocation != null) {
+        partitionsToCheck.add(this.unpartitionTableLocation);
+      }
     } else {
       partitionsToCheck.addAll(
           this.partitionToCreate.values().stream()