MTable mTable = getMTable(dbName, tableName);
MPartitionColumnStatistics mStatsObj;
List<MPartitionColumnStatistics> mStatsObjColl;
if (mTable == null) {
throw new
NoSuchObjectException("Table " + tableName +
" for which stats deletion is requested doesn't exist");
}
MPartition mPartition =
getMPartition(dbName, tableName, partVals);
if (mPartition == null) {
throw new
NoSuchObjectException("Partition " + partName +
" for which stats deletion is requested doesn't exist");
}
Query query = pm.newQuery(MPartitionColumnStatistics.class);
String filter;
String parameters;
if (colName != null) {
filter = "partition.partitionName == t1 && dbName == t2 && tableName == t3 && " +
"colName == t4";
parameters = "java.lang.String t1, java.lang.String t2, " +
"java.lang.String t3, java.lang.String t4";
} else {
filter = "partition.partitionName == t1 && dbName == t2 && tableName == t3";
parameters = "java.lang.String t1, java.lang.String t2, java.lang.String t3";
}
query.setFilter(filter);
query
.declareParameters(parameters);
if (colName != null) {
query.setUnique(true);
mStatsObj = (MPartitionColumnStatistics)query.executeWithArray(partName.trim(),
dbName.trim(), tableName.trim(), colName.trim());
pm.retrieve(mStatsObj);
if (mStatsObj != null) {
pm.deletePersistent(mStatsObj);
} else {
throw new NoSuchObjectException("Column stats doesn't exist for db=" +dbName + " table="
+ tableName + " partition=" + partName + " col=" + colName);
}
} else {
mStatsObjColl= (List<MPartitionColumnStatistics>)query.execute(partName.trim(),
dbName.trim(), tableName.trim());
pm.retrieveAll(mStatsObjColl);
if (mStatsObjColl != null) {
pm.deletePersistentAll(mStatsObjColl);
} else {
throw new NoSuchObjectException("Column stats doesn't exist for db=" + dbName +
" table=" + tableName + " partition" + partName);
}
}
ret = commitTransaction();
} catch(NoSuchObjectException e) {