dengzhhu653 commented on code in PR #5578:
URL: https://github.com/apache/hive/pull/5578#discussion_r1918039241
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java:
##########
@@ -10234,93 +10234,105 @@ protected Integer getJdoResult(GetHelper<Integer>
ctx) throws MetaException, NoS
public boolean deletePartitionColumnStatistics(String catName, String
dbName, String tableName,
String partName, List<String> partVals, String colName, String engine)
throws NoSuchObjectException, MetaException, InvalidObjectException,
InvalidInputException {
+ List<String> colNames = new ArrayList<>();
+ if (colName != null) {
+ colNames.add(colName);
+ }
+ return deletePartitionMultiColumnStatistics(catName, dbName, tableName,
partName, partVals, colNames, engine);
+ }
+
+ @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);
+ 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");
+ + " 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");
+ + " for which stats deletion is requested doesn't exist");
}
query = pm.newQuery(MPartitionColumnStatistics.class);
String filter;
String parameters;
- if (colName != null) {
- filter =
- "partition.partitionName == t1 && partition.table.database.name ==
t2 && partition.table.tableName == t3 && "
- + "colName == t4 && partition.table.database.catalogName ==
t5" + (engine != null ? " && engine == t6" : "");
- parameters =
- "java.lang.String t1, java.lang.String t2, "
- + "java.lang.String t3, java.lang.String t4, java.lang.String
t5" + (engine != null ? ", java.lang.String t6" : "");
+ if (colNames != null && !colNames.isEmpty()) {
+ 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 (colName != null) {
- query.setUnique(true);
+ if (colNames != null) {
+ List<String> normalizedColNames = new ArrayList<>();
+ for (String colName : colNames){
+ // trim the extra spaces, and change to lowercase
+ normalizedColNames.add(normalizeIdentifier(colName));
+ }
if (engine != null) {
- mStatsObj =
- (MPartitionColumnStatistics)
query.executeWithArray(partName.trim(),
- normalizeIdentifier(dbName),
- normalizeIdentifier(tableName),
- normalizeIdentifier(colName),
- normalizeIdentifier(catName),
- engine);
+ mStatsObjColl =
+ (List<MPartitionColumnStatistics>)
query.executeWithArray(partName.trim(),
+ normalizeIdentifier(dbName),
+ normalizeIdentifier(tableName),
+ normalizedColNames,
+ normalizeIdentifier(catName),
+ engine);
} else {
- mStatsObj =
- (MPartitionColumnStatistics)
query.executeWithArray(partName.trim(),
- normalizeIdentifier(dbName),
- normalizeIdentifier(tableName),
- normalizeIdentifier(colName),
- normalizeIdentifier(catName));
- }
- pm.retrieve(mStatsObj);
- if (mStatsObj != null) {
- pm.deletePersistent(mStatsObj);
+ mStatsObjColl =
+ (List<MPartitionColumnStatistics>)
query.executeWithArray(partName.trim(),
+ normalizeIdentifier(dbName),
+ normalizeIdentifier(tableName),
+ normalizedColNames,
+ normalizeIdentifier(catName));
+ }
+ pm.retrieveAll(mStatsObjColl);
+ if (mStatsObjColl != null) {
+ pm.deletePersistentAll(mStatsObjColl);
} else {
throw new NoSuchObjectException("Column stats doesn't exist for
table="
Review Comment:
nit: this exception should never throw?
--
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]