dengzhhu653 commented on code in PR #5578:
URL: https://github.com/apache/hive/pull/5578#discussion_r1945954510


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java:
##########
@@ -7420,6 +7420,97 @@ public boolean delete_partition_column_statistics(String 
dbName, String tableNam
     return ret;
   }
 
+
+  public boolean delete_column_statistics_req(DeleteColumnStatisticsRequest 
req) throws TException {
+    boolean isDeletingTableLevel = req.getPart_name() == null ? true : false;
+    // partioned or not
+    // isPartitoned
+    String dbName = req.getDb_name();
+    String tableName = req.getTbl_name();
+    List<String> colNames = req.getCol_names();
+    String partName = req.getPart_name();
+    String engine = req.getEngine();
+    dbName = dbName.toLowerCase();
+    String[] parsedDbName = parseDbName(dbName, conf);
+    tableName = tableName.toLowerCase();
+
+    if (colNames != null) {
+      for (String colName : colNames) {
+        colName = colName.toLowerCase();
+        if (isDeletingTableLevel) {
+          startFunction("delete_column_statistics_by_table", ": table=" +
+                  TableName.getQualified(parsedDbName[CAT_NAME], 
parsedDbName[DB_NAME], tableName) + " column=" +
+                  colName);
+        }
+        else {
+          startFunction("delete_column_statistics_by_partition", ": table=" +
+                  TableName.getQualified(parsedDbName[CAT_NAME], 
parsedDbName[DB_NAME], tableName) +
+                  " partition=" + partName + " column=" + colName);
+        }
+      }
+    }
+    boolean ret = false, committed = false;
+    getMS().openTransaction();
+    try {
+      Table table = getMS().getTable(parsedDbName[CAT_NAME], 
parsedDbName[DB_NAME], tableName);
+      boolean isPartitioned = table.isSetPartitionKeys() && 
table.getPartitionKeysSize() > 0;
+      if (TxnUtils.isTransactionalTable(table)) {
+        throw new MetaException("Cannot delete stats via this API for a 
transactional table");
+      }
+      if (isDeletingTableLevel && !isPartitioned){
+        ret = getMS().deleteTableMultiColumnStatistics(parsedDbName[CAT_NAME], 
parsedDbName[DB_NAME], tableName, colNames, engine);
+        if (ret && colNames != null) {
+          for (String colName : colNames) {
+            if (transactionalListeners != null && 
!transactionalListeners.isEmpty()) {
+              MetaStoreListenerNotifier.notifyEvent(transactionalListeners,
+                      EventType.DELETE_TABLE_COLUMN_STAT,
+                      new DeleteTableColumnStatEvent(parsedDbName[CAT_NAME], 
parsedDbName[DB_NAME],
+                              tableName, colName, engine, this));
+            }
+            if (!listeners.isEmpty()) {
+              MetaStoreListenerNotifier.notifyEvent(listeners,
+                      EventType.DELETE_TABLE_COLUMN_STAT,
+                      new DeleteTableColumnStatEvent(parsedDbName[CAT_NAME], 
parsedDbName[DB_NAME],
+                              tableName, colName, engine, this));
+            }
+          }
+        }
+      }
+      else {
+        if (isDeletingTableLevel){
+          ret = 
getMS().deletePartitionMultiColumnStatistics(parsedDbName[CAT_NAME], 
parsedDbName[DB_NAME], tableName,
+                  partName, null, colNames, engine);
+        }
+        List<String> partVals = getPartValsFromName(getMS(), 
parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, partName);
+        ret = 
getMS().deletePartitionMultiColumnStatistics(parsedDbName[CAT_NAME], 
parsedDbName[DB_NAME], tableName,

Review Comment:
   whether the partName is null or not, both of them can call `ret = 
getMS().deletePartitionMultiColumnStatistics(parsedDbName[CAT_NAME], 
parsedDbName[DB_NAME], tableName,
   Comment
   whether the partName is null or not, both of them can invoke 
`getMS().deletePartitionMultiColumnStatistics(parsedDbName[CAT_NAME], 
parsedDbName[DB_NAME], tableName, partName, colNames, engine);`, let RawStore 
to check the `partName` is null or not



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