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

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


The following commit(s) were added to refs/heads/master by this push:
     new 4ad7d16cb54 HIVE-27050: Iceberg: Restrict reducer extrapolation to 
contain number of small files being created for Iceberg tables (Dmitriy 
Fingerman, reviewed by Denys Kuzmenko, okumin)
4ad7d16cb54 is described below

commit 4ad7d16cb547cfcfd90ed6ad54708aabfb5878cc
Author: Dmitriy Fingerman <[email protected]>
AuthorDate: Tue Aug 1 04:12:43 2023 -0400

    HIVE-27050: Iceberg: Restrict reducer extrapolation to contain number of 
small files being created for Iceberg tables (Dmitriy Fingerman, reviewed by 
Denys Kuzmenko, okumin)
    
    Closes #4477
---
 .../java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java 
b/ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java
index c4594036a3a..1d2eab7e144 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezUtils.java
@@ -27,6 +27,8 @@ import java.util.stream.Collectors;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.ql.Context;
+import org.apache.hadoop.hive.ql.ddl.DDLUtils;
 import org.apache.hadoop.hive.ql.exec.AbstractFileMergeOperator;
 import org.apache.hadoop.hive.ql.exec.AppMasterEventOperator;
 import org.apache.hadoop.hive.ql.exec.FetchTask;
@@ -42,7 +44,9 @@ import org.apache.hadoop.hive.ql.exec.SerializationUtilities;
 import org.apache.hadoop.hive.ql.exec.TableScanOperator;
 import org.apache.hadoop.hive.ql.exec.UnionOperator;
 import org.apache.hadoop.hive.ql.exec.Utilities;
+import org.apache.hadoop.hive.ql.hooks.WriteEntity;
 import org.apache.hadoop.hive.ql.lib.*;
+import org.apache.hadoop.hive.ql.metadata.Table;
 import org.apache.hadoop.hive.ql.optimizer.GenMapRedUtils;
 import org.apache.hadoop.hive.ql.plan.*;
 import org.apache.hadoop.hive.ql.plan.TezEdgeProperty.EdgeType;
@@ -77,6 +81,11 @@ public class GenTezUtils {
     return unionWork;
   }
 
+  private static boolean isRestrictReducerExtrapolation(Context context) {
+    return context.getOperation() == Context.Operation.DELETE && 
context.getLoadTableOutputMap().values()
+            
.stream().map(WriteEntity::getTable).anyMatch(DDLUtils::isIcebergTable);
+  }
+
   public static ReduceWork createReduceWork(
       GenTezProcContext context, Operator<?> root, TezWork tezWork) {
     assert !root.getParentOperators().isEmpty();
@@ -125,9 +134,15 @@ public class GenTezUtils {
       int minPartition = Math.max(1, (int) (nReducers * minPartitionFactor));
       minPartition = (minPartition > maxReducers) ? maxReducers : minPartition;
 
+      if (isRestrictReducerExtrapolation(context.parseContext.getContext())) {
+        LOG.debug("Overriding maxPartitionFactor to 1.0 to prevent creation of 
small files after delete operation");
+        maxPartitionFactor = 1f;
+      }
+      
       // max we allow tez to pick
       int maxPartition = Math.max(1, (int) (nReducers * maxPartitionFactor));
       maxPartition = (maxPartition > maxReducers) ? maxReducers : maxPartition;
+      LOG.debug("max partition factor={}, max partition={}", 
maxPartitionFactor, maxPartition);
 
       // reduce only if the parameters are significant
       final float minThreshold = 
context.conf.getFloatVar(HiveConf.ConfVars.TEZ_AUTO_REDUCER_PARALLELISM_MIN_THRESHOLD);

Reply via email to