dengzhhu653 commented on code in PR #5578: URL: https://github.com/apache/hive/pull/5578#discussion_r1916289359
########## standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java: ########## @@ -10420,6 +10522,100 @@ public boolean deleteTableColumnStatistics(String catName, String dbName, String return ret; } + @Override + public boolean deleteTableMultiColumnStatistics(String catName, String dbName, String tableName, + List<String> colNames, String engine) + throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException { + boolean ret = false; + Query query = null; + dbName = org.apache.commons.lang3.StringUtils.defaultString(dbName, + Warehouse.DEFAULT_DATABASE_NAME); + if (tableName == null) { + throw new InvalidInputException("Table name is null."); + } + try { + openTransaction(); + MTable mTable = getMTable(catName, dbName, tableName); + MTableColumnStatistics mStatsObj; + List<MTableColumnStatistics> mStatsObjColl; + if (mTable == null) { + throw new NoSuchObjectException("Table " + + TableName.getQualified(catName, dbName, tableName) + + " for which stats deletion is requested doesn't exist"); + } + // Note: this does not verify ACID state; called internally when removing cols/etc. + // Also called via an unused metastore API that checks for ACID tables. + query = pm.newQuery(MTableColumnStatistics.class); + String filter; + String parameters; + if (colNames != null) { + filter = "table.tableName == t1 && table.database.name == t2 && table.database.catalogName == t3 && t4.contains(colName)" + (engine != null ? " && engine == t5" : ""); + parameters = "java.lang.String t1, java.lang.String t2, java.lang.String t3, java.util.Collection t4" + (engine != null ? ", java.lang.String t5" : ""); + } else { + filter = "table.tableName == t1 && table.database.name == t2 && table.database.catalogName == t3" + (engine != null ? " && engine == t4" : ""); + parameters = "java.lang.String t1, java.lang.String t2, java.lang.String t3" + (engine != null ? ", java.lang.String t4" : ""); + } + + query.setFilter(filter); + query.declareParameters(parameters); + if (colNames != null) { + query.setUnique(true); + for (String colName : colNames){ + // trim the extra spaces, and change to lowercase + normalizeIdentifier(colName); + } + if (engine != null) { + mStatsObj = + (MTableColumnStatistics) query.executeWithArray(normalizeIdentifier(tableName), + normalizeIdentifier(dbName), + normalizeIdentifier(catName), + colNames, + engine); + } else { + mStatsObj = + (MTableColumnStatistics) query.executeWithArray(normalizeIdentifier(tableName), + normalizeIdentifier(dbName), + normalizeIdentifier(catName), + colNames); + } + pm.retrieve(mStatsObj); + + if (mStatsObj != null) { + pm.deletePersistent(mStatsObj); + } else { + throw new NoSuchObjectException("Column stats doesn't exist for db=" + dbName + " table=" + + tableName + " col=" + String.join(", ", colNames)); + } + } else { Review Comment: merge the if else -- 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