deniskuzZ commented on code in PR #5814:
URL: https://github.com/apache/hive/pull/5814#discussion_r2163346022


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java:
##########
@@ -412,23 +412,41 @@ public List<Void> run(List<Partition> input) throws 
Exception {
 
             if (cascade || retainOnColRemoval) {
               parts = msdb.getPartitions(catName, dbname, name, -1);
-              for (Partition part : parts) {
-                Partition oldPart = new Partition(part);
-                List<FieldSchema> oldCols = part.getSd().getCols();
-                part.getSd().setCols(newt.getSd().getCols());
-                List<ColumnStatistics> colStats = 
updateOrGetPartitionColumnStats(msdb, catName, dbname, name,
-                    part.getValues(), oldCols, oldt, part, null, null);
-                assert (colStats.isEmpty());
-                Deadline.checkTimeout();
-                if (cascade) {
-                  msdb.alterPartition(
-                    catName, dbname, name, part.getValues(), part, 
writeIdList);
-                } else {
+              String catalogName = catName;
+              String databaseName = dbname;
+              String tableName = name;
+              Table finalOldt = oldt;
+              int partitionBatchSize = 
MetastoreConf.getIntVar(handler.getConf(),
+                      MetastoreConf.ConfVars.BATCH_RETRIEVE_MAX);
+              Batchable.runBatched(partitionBatchSize, parts, new 
Batchable<Partition, Void>() {
+                @Override
+                public List<Void> run(List<Partition> input) throws Exception {
+                  List<Partition> oldParts = new ArrayList<>(input.size());
+                  List<List<String>> partVals = 
input.stream().map(Partition::getValues).collect(Collectors.toList());
                   // update changed properties (stats)
-                  oldPart.setParameters(part.getParameters());
-                  msdb.alterPartition(catName, dbname, name, part.getValues(), 
oldPart, writeIdList);
+                  for (Partition part : input) {
+                    Partition oldPart = new Partition(part);
+                    List<FieldSchema> oldCols = part.getSd().getCols();
+                    part.getSd().setCols(newt.getSd().getCols());
+                    List<ColumnStatistics> colStats = 
updateOrGetPartitionColumnStats(msdb, catalogName, databaseName,
+                            tableName, part.getValues(), oldCols, finalOldt, 
part, null, null);
+                    assert (colStats.isEmpty());
+                    if (!cascade) {
+                      oldPart.setParameters(part.getParameters());
+                      oldParts.add(oldPart);
+                    }
+                  }
+                  Deadline.checkTimeout();
+                  if (cascade) {
+                    msdb.alterPartitions(catalogName, databaseName, tableName, 
partVals, input, newt.getWriteId(),
+                            writeIdList);
+                  } else {
+                    msdb.alterPartitions(catalogName, newDbName, newTblName, 
partVals, oldParts, newt.getWriteId(),

Review Comment:
   @vikramahuja1001, why do you use `newDbName` , `newTblName` here ?



-- 
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: gitbox-unsubscr...@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to