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

dengzh 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 990617a7b29 HIVE-28668: Hive should emit fewer events for truncate 
table operation (#5582)
990617a7b29 is described below

commit 990617a7b295c3516f69efd571029ec23fa21e56
Author: Sai Hemanth Gantasala 
<[email protected]>
AuthorDate: Mon Feb 10 16:44:47 2025 -0800

    HIVE-28668: Hive should emit fewer events for truncate table operation 
(#5582)
---
 .../listener/TestDbNotificationListener.java       |  43 ++++++
 .../load/message/TruncatePartitionHandler.java     |  54 +++++--
 .../apache/hadoop/hive/metastore/AlterHandler.java |  66 +++++----
 .../apache/hadoop/hive/metastore/HMSHandler.java   | 163 +++++++++++----------
 .../hadoop/hive/metastore/HiveAlterHandler.java    |   8 +-
 5 files changed, 209 insertions(+), 125 deletions(-)

diff --git 
a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
 
b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
index dec716089c5..50d40cded68 100644
--- 
a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
+++ 
b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
@@ -857,6 +857,49 @@ public void alterPartitions() throws Exception {
     testEventCounts(defaultDbName, firstEventId, null, null, 3);
   }
 
+  @Test
+  public void testTruncatePartitionedTable() throws Exception {
+    String defaultDbName = "default";
+    String unPartitionedTblName = "unPartitionedTable";
+    new TableBuilder()
+        .setDbName(defaultDbName)
+        .setTableName(unPartitionedTblName)
+        .addCol("col1", "int")
+        .setLocation(testTempDir)
+        .create(msClient, new HiveConf());
+
+    Table table = msClient.getTable(new GetTableRequest(defaultDbName,
+        unPartitionedTblName));
+    msClient.truncateTable(defaultDbName, unPartitionedTblName, null);
+    NotificationEventResponse rsp = msClient.getNextNotification(firstEventId, 
0, null);
+    assertEquals(2, rsp.getEventsSize()); // create unpartitioned table + 
alter table events
+
+    String partitionedTblName = "partitionedTbl";
+    new TableBuilder()
+        .setDbName(defaultDbName)
+        .setTableName(partitionedTblName)
+        .addCol("col1", "int")
+        .addPartCol("col2", "int")
+        .addPartCol("col3", "string")
+        .setLocation(testTempDir)
+        .create(msClient, new HiveConf());
+    table = msClient.getTable(new GetTableRequest(defaultDbName,
+        partitionedTblName));
+    List<Partition> partitions = new ArrayList<>();
+    for (int i = 0; i < 5; i++) {
+      List<String> values = Arrays.asList(i + "", "part" + i);
+      Partition part = new Partition(values, defaultDbName, partitionedTblName,
+          0,  0, table.getSd(), emptyParameters);
+      partitions.add(part);
+    }
+    msClient.add_partitions(partitions);
+    msClient.truncateTable(defaultDbName, partitionedTblName, null);
+    rsp = msClient.getNextNotification(firstEventId, 0, null);
+    // 5 events - create unpartitioned table, alter table events
+    // create partitioned table, add partition, alter table events.
+    assertEquals(5, rsp.getEventsSize());
+  }
+
   @Test
   public void dropPartition() throws Exception {
     String defaultDbName = "default";
diff --git 
a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/load/message/TruncatePartitionHandler.java
 
b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/load/message/TruncatePartitionHandler.java
index 2af9f1354a2..341752de366 100644
--- 
a/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/load/message/TruncatePartitionHandler.java
+++ 
b/ql/src/java/org/apache/hadoop/hive/ql/parse/repl/load/message/TruncatePartitionHandler.java
@@ -19,7 +19,10 @@
 
 import org.apache.hadoop.hive.common.TableName;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hadoop.hive.metastore.api.Partition;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
 import org.apache.hadoop.hive.metastore.messaging.AlterPartitionMessage;
+import org.apache.hadoop.hive.metastore.messaging.AlterPartitionsMessage;
 import org.apache.hadoop.hive.ql.ddl.DDLWork;
 import org.apache.hadoop.hive.ql.ddl.table.misc.truncate.TruncateTableDesc;
 import org.apache.hadoop.hive.ql.exec.Task;
@@ -27,6 +30,7 @@
 import org.apache.hadoop.hive.ql.exec.repl.util.ReplUtils;
 import org.apache.hadoop.hive.ql.parse.SemanticException;
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -35,17 +39,38 @@
 public class TruncatePartitionHandler extends AbstractMessageHandler {
   @Override
   public List<Task<?>> handle(Context context) throws SemanticException {
-    AlterPartitionMessage msg = 
deserializer.getAlterPartitionMessage(context.dmd.getPayload());
-    final TableName tName = TableName.fromString(msg.getTable(), null,
-        context.isDbNameEmpty() ? msg.getDB() : context.dbName);
-
-    Map<String, String> partSpec = new LinkedHashMap<>();
+    final TableName tName;
     org.apache.hadoop.hive.metastore.api.Table tblObj;
     try {
-      tblObj = msg.getTableObj();
-      Iterator<String> afterIterator = 
msg.getPtnObjAfter().getValuesIterator();
-      for (FieldSchema fs : tblObj.getPartitionKeys()) {
-        partSpec.put(fs.getName(), afterIterator.next());
+      if (MetastoreConf.getBoolVar(context.hiveConf,
+          MetastoreConf.ConfVars.NOTIFICATION_ALTER_PARTITIONS_V2_ENABLED)) {
+        AlterPartitionsMessage singleMsg = 
deserializer.getAlterPartitionsMessage(
+            context.dmd.getPayload());
+        tblObj = singleMsg.getTableObj();
+        tName = TableName.fromString(singleMsg.getTable(), null,
+            context.isDbNameEmpty() ? singleMsg.getDB() : context.dbName);
+        List<Map<String, String>> afterPartitionsList = 
singleMsg.getPartitions();
+        List<Task<?>> childTaskList = new ArrayList<>();
+        for(Map<String, String> afterIteratorMap : afterPartitionsList) {
+          Map<String, String> partSpec = new LinkedHashMap<>();
+          for (FieldSchema fs : tblObj.getPartitionKeys()) {
+            partSpec.put(fs.getName(), afterIteratorMap.get(fs.getName()));
+          }
+          childTaskList.addAll(handleSingleAlterPartition(context, tName, 
partSpec,
+              singleMsg.getWriteId()));
+        }
+        return childTaskList;
+      } else {
+        AlterPartitionMessage msg = 
deserializer.getAlterPartitionMessage(context.dmd.getPayload());
+        tName = TableName.fromString(msg.getTable(), null,
+            context.isDbNameEmpty() ? msg.getDB() : context.dbName);
+        tblObj = msg.getTableObj();
+        Iterator<String> afterIterator = 
msg.getPtnObjAfter().getValuesIterator();
+        Map<String, String> partSpec = new LinkedHashMap<>();
+        for (FieldSchema fs : tblObj.getPartitionKeys()) {
+          partSpec.put(fs.getName(), afterIterator.next());
+        }
+        return handleSingleAlterPartition(context, tName, partSpec, 
msg.getWriteId());
       }
     } catch (Exception e) {
       if (!(e instanceof SemanticException)) {
@@ -54,18 +79,19 @@ public List<Task<?>> handle(Context context) throws 
SemanticException {
         throw (SemanticException) e;
       }
     }
+  }
 
+  private List<Task<?>> handleSingleAlterPartition(Context context, TableName 
tName,
+      Map<String, String> partSpec, Long writeId) throws SemanticException {
     TruncateTableDesc truncateTableDesc = new TruncateTableDesc(
-            tName, partSpec,
-            context.eventOnlyReplicationSpec());
-    truncateTableDesc.setWriteId(msg.getWriteId());
+        tName, partSpec, context.eventOnlyReplicationSpec());
+    truncateTableDesc.setWriteId(writeId);
     Task<DDLWork> truncatePtnTask = TaskFactory.get(
         new DDLWork(readEntitySet, writeEntitySet, truncateTableDesc, true,
-                context.getDumpDirectory(), context.getMetricCollector()), 
context.hiveConf);
+            context.getDumpDirectory(), context.getMetricCollector()), 
context.hiveConf);
     context.log.debug("Added truncate ptn task : {}:{}:{}", 
truncatePtnTask.getId(),
         truncateTableDesc.getTableName(), truncateTableDesc.getWriteId());
     updatedMetadata.set(context.dmd.getEventTo().toString(), tName.getDb(), 
tName.getTable(), partSpec);
-
     try {
       return ReplUtils.addChildTask(truncatePtnTask);
     } catch (Exception e) {
diff --git 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/AlterHandler.java
 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/AlterHandler.java
index 6edbef39397..2595da5e42e 100644
--- 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/AlterHandler.java
+++ 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/AlterHandler.java
@@ -53,6 +53,8 @@ public interface AlterHandler extends Configurable {
    *          <i>newTable.tableName</i> if alter op is not a rename.
    * @param newTable
    *          new table object
+   * @param envContext
+   *          environment context variable
    * @throws InvalidOperationException
    *           thrown if the newTable object is invalid
    * @throws MetaException
@@ -82,6 +84,8 @@ default void alterTable(RawStore msdb, Warehouse wh, String 
catName, String dbna
    *          new table object
    * @param handler
    *          HMSHandle object (required to log event notification)
+   * @param writeIdList write id list for the table
+   * @param envContext environment context variable
    * @throws InvalidOperationException
    *           thrown if the newTable object is invalid
    * @throws MetaException
@@ -101,6 +105,7 @@ void alterTable(RawStore msdb, Warehouse wh, String 
catName, String dbname,
    * @param msdb
    *          object to get metadata
    * @param wh
+   *          physical warehouse class
    * @param dbname
    *          database of the partition being altered
    * @param name
@@ -110,10 +115,11 @@ void alterTable(RawStore msdb, Warehouse wh, String 
catName, String dbname,
    * @param new_part
    *          new partition object
    * @return the altered partition
-   * @throws InvalidOperationException
-   * @throws InvalidObjectException
-   * @throws AlreadyExistsException
-   * @throws MetaException
+   * @throws InvalidOperationException thrown if the operation is invalid
+   * @throws InvalidObjectException thrown if the new_part object is invalid
+   * @throws AlreadyExistsException thrown if the new_part object already 
exists
+   * @throws MetaException thrown if there is any other error
+   * @throws NoSuchObjectException thrown if there is no such object
    */
   @Deprecated
   Partition alterPartition(final RawStore msdb, Warehouse wh, final String 
dbname,
@@ -136,13 +142,16 @@ Partition alterPartition(final RawStore msdb, Warehouse 
wh, final String dbname,
    *          original values of the partition being altered
    * @param new_part
    *          new partition object
+   * @param environmentContext environment context variable
    * @param handler
    *          HMSHandle object (required to log event notification)
+   * @param validWriteIds valid write id list for the table
    * @return the altered partition
-   * @throws InvalidOperationException
-   * @throws InvalidObjectException
-   * @throws AlreadyExistsException
-   * @throws MetaException
+   * @throws InvalidOperationException thrown if the operation is invalid
+   * @throws InvalidObjectException thrown if the new_part object is invalid
+   * @throws AlreadyExistsException thrown if the new_part object already 
exists
+   * @throws MetaException thrown if there is any other error
+   * @throws NoSuchObjectException thrown if there is no such object
    */
   Partition alterPartition(final RawStore msdb, Warehouse wh, final String 
catName,
                            final String dbname, final String name, final 
List<String> part_vals,
@@ -158,18 +167,19 @@ Partition alterPartition(final RawStore msdb, Warehouse 
wh, final String catName
    *
    * @param msdb
    *          object to get metadata
-   * @param wh
+   * @param wh physical warehouse class
    * @param dbname
    *          database of the partition being altered
    * @param name
    *          table of the partition being altered
    * @param new_parts
    *          new partition list
+   * @param environmentContext environment context variable
    * @return the altered partition list
-   * @throws InvalidOperationException
-   * @throws InvalidObjectException
-   * @throws AlreadyExistsException
-   * @throws MetaException
+   * @throws InvalidOperationException thrown if the operation is invalid
+   * @throws InvalidObjectException thrown if the new_parts object is invalid
+   * @throws AlreadyExistsException thrown if the new_part object already 
exists
+   * @throws MetaException thrown if there is any other error
    */
   @Deprecated
   List<Partition> alterPartitions(final RawStore msdb, Warehouse wh,
@@ -179,23 +189,21 @@ List<Partition> alterPartitions(final RawStore msdb, 
Warehouse wh,
 
   /**
    * handles alter partitions
-   *
-   * @param msdb
-   *          object to get metadata
-   * @param wh
-   * @param dbname
-   *          database of the partition being altered
-   * @param name
-   *          table of the partition being altered
-   * @param new_parts
-   *          new partition list
-   * @param handler
-   *          HMSHandle object (required to log event notification)
+   * @param msdb object to get metadata
+   * @param wh physical warehouse class
+   * @param catName catalog name of the partition being altered
+   * @param dbname database of the partition being altered
+   * @param name table of the partition being altered
+   * @param new_parts new partition list
+   * @param environmentContext environment context variable
+   * @param writeIdList write id list for the table
+   * @param writeId writeId for the table
+   * @param handler HMSHandle object (required to log event notification)
    * @return the altered partition list
-   * @throws InvalidOperationException
-   * @throws InvalidObjectException
-   * @throws AlreadyExistsException
-   * @throws MetaException
+   * @throws InvalidOperationException thrown if the operation is invalid
+   * @throws InvalidObjectException thrown if the new_parts object is invalid
+   * @throws AlreadyExistsException thrown if the new_part object already 
exists
+   * @throws MetaException thrown if there is any other error
    */
   List<Partition> alterPartitions(final RawStore msdb, Warehouse wh, final 
String catName,
     final String dbname, final String name, final List<Partition> new_parts,
diff --git 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
index 2c1e53b11d6..e4a3b68b690 100644
--- 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
+++ 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
@@ -3362,95 +3362,95 @@ private void updateStatsForTruncate(Map<String,String> 
props, EnvironmentContext
     return;
   }
 
-  private void alterPartitionForTruncate(RawStore ms, String catName, String 
dbName, String tableName,
-                                         Table table, Partition partition, 
String validWriteIds, long writeId) throws Exception {
+  private void alterPartitionsForTruncate(RawStore ms, String catName, String 
dbName, String tableName,
+      Table table, List<Partition> partitions, String validWriteIds, long 
writeId) throws Exception {
     EnvironmentContext environmentContext = new EnvironmentContext();
-    updateStatsForTruncate(partition.getParameters(), environmentContext);
-
-    if (!transactionalListeners.isEmpty()) {
-      MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-          EventType.ALTER_PARTITION,
-          new AlterPartitionEvent(partition, partition, table, true, true,
-              writeId, this));
+    if (partitions.isEmpty()) {
+      return;
     }
-
-    if (!listeners.isEmpty()) {
-      MetaStoreListenerNotifier.notifyEvent(listeners,
-          EventType.ALTER_PARTITION,
-          new AlterPartitionEvent(partition, partition, table, true, true,
-              writeId, this));
+    List<List<String>> partValsList = new ArrayList<>();
+    for (Partition partition: partitions) {
+      updateStatsForTruncate(partition.getParameters(), environmentContext);
+      if (writeId > 0) {
+        partition.setWriteId(writeId);
+      }
+      partition.putToParameters(hive_metastoreConstants.DDL_TIME, 
Long.toString(System
+          .currentTimeMillis() / 1000));
+      partValsList.add(partition.getValues());
+    }
+    ms.alterPartitions(catName, dbName, tableName, partValsList, partitions, 
writeId, validWriteIds);
+    if (transactionalListeners != null && !transactionalListeners.isEmpty()) {
+      boolean shouldSendSingleEvent = MetastoreConf.getBoolVar(this.getConf(),
+          MetastoreConf.ConfVars.NOTIFICATION_ALTER_PARTITIONS_V2_ENABLED);
+      if (shouldSendSingleEvent) {
+        MetaStoreListenerNotifier.notifyEvent(transactionalListeners, 
EventMessage.EventType.ALTER_PARTITIONS,
+            new AlterPartitionsEvent(partitions, partitions, table, true, 
true, this), environmentContext);
+      } else {
+        for (Partition partition : partitions) {
+          MetaStoreListenerNotifier.notifyEvent(transactionalListeners, 
EventMessage.EventType.ALTER_PARTITION,
+              new AlterPartitionEvent(partition, partition, table, true, true, 
partition.getWriteId(), this),
+              environmentContext);
+        }
+      }
     }
-
-    if (writeId > 0) {
-      partition.setWriteId(writeId);
+    if (listeners != null && !listeners.isEmpty()) {
+      boolean shouldSendSingleEvent = MetastoreConf.getBoolVar(this.getConf(),
+          MetastoreConf.ConfVars.NOTIFICATION_ALTER_PARTITIONS_V2_ENABLED);
+      if (shouldSendSingleEvent) {
+        MetaStoreListenerNotifier.notifyEvent(listeners, 
EventMessage.EventType.ALTER_PARTITIONS,
+            new AlterPartitionsEvent(partitions, partitions, table, true, 
true, this), environmentContext);
+      } else {
+        for (Partition partition : partitions) {
+          MetaStoreListenerNotifier.notifyEvent(listeners, 
EventMessage.EventType.ALTER_PARTITION,
+              new AlterPartitionEvent(partition, partition, table, true, true, 
partition.getWriteId(), this),
+              environmentContext);
+        }
+      }
     }
-    alterHandler.alterPartition(ms, wh, catName, dbName, tableName, null, 
partition,
-        environmentContext, this, validWriteIds);
   }
 
   private void alterTableStatsForTruncate(RawStore ms, String catName, String 
dbName,
-                                          String tableName, Table table, 
List<String> partNames,
-                                          String validWriteIds, long writeId) 
throws Exception {
-    if (partNames == null) {
-      if (0 != table.getPartitionKeysSize()) {
-        for (Partition partition : ms.getPartitions(catName, dbName, 
tableName, -1)) {
-          alterPartitionForTruncate(ms, catName, dbName, tableName, table, 
partition,
-              validWriteIds, writeId);
-        }
-      } else {
-        EnvironmentContext environmentContext = new EnvironmentContext();
-        updateStatsForTruncate(table.getParameters(), environmentContext);
-
-        boolean isReplicated = isDbReplicationTarget(ms.getDatabase(catName, 
dbName));
-        if (!transactionalListeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
-              EventType.ALTER_TABLE,
-              new AlterTableEvent(table, table, true, true,
-                  writeId, this, isReplicated));
-        }
-
-        if (!listeners.isEmpty()) {
-          MetaStoreListenerNotifier.notifyEvent(listeners,
-              EventType.ALTER_TABLE,
-              new AlterTableEvent(table, table, true, true,
-                  writeId, this, isReplicated));
-        }
+      String tableName, Table table, List<Partition> partitionsList,
+      String validWriteIds, long writeId) throws Exception {
+    if (0 != table.getPartitionKeysSize()) {
+      alterPartitionsForTruncate(ms, catName, dbName, tableName, table, 
partitionsList,
+          validWriteIds, writeId);
+    } else {
+      EnvironmentContext environmentContext = new EnvironmentContext();
+      updateStatsForTruncate(table.getParameters(), environmentContext);
+      boolean isReplicated = isDbReplicationTarget(ms.getDatabase(catName, 
dbName));
+      if (!transactionalListeners.isEmpty()) {
+        MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+            EventType.ALTER_TABLE,
+            new AlterTableEvent(table, table, true, true,
+                writeId, this, isReplicated));
+      }
 
-        // TODO: this should actually pass thru and set writeId for txn stats.
-        if (writeId > 0) {
-          table.setWriteId(writeId);
-        }
-        alterHandler.alterTable(ms, wh, catName, dbName, tableName, table,
-            environmentContext, this, validWriteIds);
+      if (!listeners.isEmpty()) {
+        MetaStoreListenerNotifier.notifyEvent(listeners,
+            EventType.ALTER_TABLE,
+            new AlterTableEvent(table, table, true, true,
+                writeId, this, isReplicated));
       }
-    } else {
-      for (Partition partition : ms.getPartitionsByNames(catName, dbName, 
tableName, partNames)) {
-        alterPartitionForTruncate(ms, catName, dbName, tableName, table, 
partition,
-            validWriteIds, writeId);
+      // TODO: this should actually pass thru and set writeId for txn stats.
+      if (writeId > 0) {
+        table.setWriteId(writeId);
       }
+      ms.alterTable(catName, dbName, tableName, table, validWriteIds);
     }
     return;
   }
 
-  private List<Path> getLocationsForTruncate(final RawStore ms,
-                                             final String catName,
-                                             final String dbName,
-                                             final String tableName,
-                                             final Table table,
-                                             final List<String> partNames) 
throws Exception {
+  private List<Path> getLocationsForTruncate(final RawStore ms, final String 
catName,
+      final String dbName, final String tableName, final Table table,
+      List<Partition> partitionsList)  throws Exception {
     List<Path> locations = new ArrayList<>();
-    if (partNames == null) {
-      if (0 != table.getPartitionKeysSize()) {
-        for (Partition partition : ms.getPartitions(catName, dbName, 
tableName, -1)) {
-          locations.add(new Path(partition.getSd().getLocation()));
-        }
-      } else {
-        locations.add(new Path(table.getSd().getLocation()));
-      }
-    } else {
-      for (Partition partition : ms.getPartitionsByNames(catName, dbName, 
tableName, partNames)) {
+    if (0 != table.getPartitionKeysSize()) {
+      for (Partition partition : partitionsList) {
         locations.add(new Path(partition.getSd().getLocation()));
       }
+    } else {
+      locations.add(new Path(table.getSd().getLocation()));
     }
     return locations;
   }
@@ -3490,7 +3490,16 @@ private void truncateTableInternal(String dbName, String 
tableName, List<String>
           .map(prop -> prop.get(TRUNCATE_SKIP_DATA_DELETION))
           .map(Boolean::parseBoolean)
           .orElse(false);
-
+      List<Partition> partitionsList = new ArrayList<>();
+      if (partNames == null) {
+        if (0 != tbl.getPartitionKeysSize()) {
+          partitionsList = getMS().getPartitions(parsedDbName[CAT_NAME], 
parsedDbName[DB_NAME],
+              tableName, -1);
+        }
+      } else {
+        partitionsList = getMS().getPartitionsByNames(parsedDbName[CAT_NAME], 
parsedDbName[DB_NAME],
+            tableName, partNames);
+      }
       if (TxnUtils.isTransactionalTable(tbl) || !skipDataDeletion) {
         if (!skipDataDeletion) {
           isSkipTrash = MetaStoreUtils.isSkipTrash(tbl.getParameters());
@@ -3500,7 +3509,7 @@ private void truncateTableInternal(String dbName, String 
tableName, List<String>
         }
         // This is not transactional
         for (Path location : getLocationsForTruncate(getMS(), 
parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName,
-            tbl, partNames)) {
+            tbl, partitionsList)) {
           if (!skipDataDeletion) {
             truncateDataFiles(location, isSkipTrash, needCmRecycle);
           } else {
@@ -3513,7 +3522,7 @@ private void truncateTableInternal(String dbName, String 
tableName, List<String>
 
       // Alter the table/partition stats and also notify truncate table event
       alterTableStatsForTruncate(getMS(), parsedDbName[CAT_NAME], 
parsedDbName[DB_NAME],
-          tableName, tbl, partNames, validWriteIds, writeId);
+          tableName, tbl, partitionsList, validWriteIds, writeId);
     } catch (Exception e) {
       throw handleException(e).throwIfInstance(MetaException.class, 
NoSuchObjectException.class)
           .convertIfInstance(IOException.class, MetaException.class)
@@ -6141,8 +6150,8 @@ private void 
alter_partitions_with_environment_context(String catName, String db
         }
         firePreEvent(new PreAlterPartitionEvent(db_name, tbl_name, table, 
null, tmpPart, this));
       }
-      oldParts = alterHandler.alterPartitions(getMS(), wh,
-          catName, db_name, tbl_name, new_parts, environmentContext, 
writeIdList, writeId, this);
+      oldParts = alterHandler.alterPartitions(getMS(), wh, catName, db_name, 
tbl_name, new_parts,
+          environmentContext, writeIdList, writeId, this);
       Iterator<Partition> olditr = oldParts.iterator();
 
       for (Partition tmpPart : new_parts) {
diff --git 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java
 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java
index fbbbca8cb49..c9586dfe6b9 100644
--- 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java
+++ 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java
@@ -826,11 +826,9 @@ private Map<List<String>, Partition> 
getExistingPartitions(final RawStore msdb,
 
   @Override
   public List<Partition> alterPartitions(final RawStore msdb, Warehouse wh, 
final String catName,
-                                         final String dbname, final String 
name,
-                                         final List<Partition> new_parts,
-                                         EnvironmentContext environmentContext,
-                                         String writeIdList, long writeId,
-                                         IHMSHandler handler)
+      final String dbname, final String name, final List<Partition> new_parts,
+      EnvironmentContext environmentContext, String writeIdList, long writeId,
+      IHMSHandler handler)
       throws InvalidOperationException, InvalidObjectException, 
AlreadyExistsException, MetaException {
     List<Partition> oldParts = new ArrayList<>();
     List<List<String>> partValsList = new ArrayList<>();

Reply via email to