dengzhhu653 commented on code in PR #5578:
URL: https://github.com/apache/hive/pull/5578#discussion_r1916285976
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java:
##########
@@ -10330,6 +10330,108 @@ public boolean deletePartitionColumnStatistics(String
catName, String dbName, St
return ret;
}
+ @Override
+ public boolean deletePartitionMultiColumnStatistics(String catName, String
dbName, String tableName,
+ String partName, List<String>
partVals, 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);
+ catName = normalizeIdentifier(catName);
+ if (tableName == null) {
+ throw new InvalidInputException("Table name is null.");
+ }
+ try {
+ openTransaction();
+ MTable mTable = getMTable(catName, dbName, tableName);
+ MPartitionColumnStatistics mStatsObj;
+ List<MPartitionColumnStatistics> mStatsObjColl;
+ if (mTable == null) {
+ throw new NoSuchObjectException("Table " + 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.
+ MPartition mPartition = getMPartition(catName, dbName, tableName,
partVals, mTable);
+ if (mPartition == null) {
+ throw new NoSuchObjectException("Partition " + partName
+ + " for which stats deletion is requested doesn't exist");
+ }
+ query = pm.newQuery(MPartitionColumnStatistics.class);
+ String filter;
+ String parameters;
+ if (colNames != null) {
+ filter = "partition.partitionName == t1 &&
partition.table.database.name == t2 && partition.table.tableName == t3 && "
+ + "t4.contains(colName) &&
partition.table.database.catalogName == t5" + (engine != null ? " && engine ==
t6" : "");
+ parameters = "java.lang.String t1, java.lang.String t2,
java.lang.String t3, "
+ + "java.util.Collection t4, java.lang.String t5" + (engine !=
null ? ", java.lang.String t6" : "");
+ } else {
+ filter = "partition.partitionName == t1 &&
partition.table.database.name == t2 && partition.table.tableName == t3 &&
partition.table.database.catalogName == t4" + (engine != null ? " && engine ==
t5" : "");
+ parameters = "java.lang.String t1, java.lang.String t2,
java.lang.String t3, java.lang.String t4" + (engine != null ? ",
java.lang.String t5" : "");
+ }
+ 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 =
+ (MPartitionColumnStatistics)
query.executeWithArray(partName.trim(),
+ normalizeIdentifier(dbName),
+ normalizeIdentifier(tableName),
+ colNames,
+ normalizeIdentifier(catName),
+ engine);
+ } else {
+ mStatsObj =
+ (MPartitionColumnStatistics)
query.executeWithArray(partName.trim(),
+ normalizeIdentifier(dbName),
+ normalizeIdentifier(tableName),
+ colNames,
+ normalizeIdentifier(catName));
+ }
+ pm.retrieve(mStatsObj);
+ if (mStatsObj != null) {
+ pm.deletePersistent(mStatsObj);
+ } else {
+ throw new NoSuchObjectException("Column stats doesn't exist for
table="
+ + TableName.getQualified(catName, dbName, tableName) +
+ " partition=" + partName + " col=" + String.join(", ",
colNames));
+ }
+ } else {
+ if (engine != null) {
+ mStatsObjColl =
+ (List<MPartitionColumnStatistics>)
query.executeWithArray(partName.trim(),
+ normalizeIdentifier(dbName),
+ normalizeIdentifier(tableName),
+ normalizeIdentifier(catName),
+ engine);
+ } else {
+ mStatsObjColl =
+ (List<MPartitionColumnStatistics>)
query.executeWithArray(partName.trim(),
+ normalizeIdentifier(dbName),
+ normalizeIdentifier(tableName),
+ normalizeIdentifier(catName));
+ }
+ pm.retrieveAll(mStatsObjColl);
+ if (mStatsObjColl != null) {
+ pm.deletePersistentAll(mStatsObjColl);
+ } else {
+ throw new NoSuchObjectException("Column stats don't exist for table="
+ + TableName.getQualified(catName, dbName, tableName) + "
partition" + partName);
+ }
+ }
+ ret = commitTransaction();
Review Comment:
after deleting the column stats, should we mark the `COLUMN_STATS_ACCURATE`
to false in partition's parameters?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]