@@ -10234,30 +10234,47 @@ protected Integer getJdoResult(GetHelper<Integer> ctx) throws MetaException, NoS
1023410234 public boolean deletePartitionColumnStatistics(String catName, String dbName, String tableName,
1023510235 String partName, List<String> partVals, String colName, String engine)
1023610236 throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException {
10237- boolean ret = false;
10238- Query query = null;
1023910237 dbName = org.apache.commons.lang3.StringUtils.defaultString(dbName,
1024010238 Warehouse.DEFAULT_DATABASE_NAME);
1024110239 catName = normalizeIdentifier(catName);
1024210240 if (tableName == null) {
1024310241 throw new InvalidInputException("Table name is null.");
1024410242 }
10243+ // Note: this does not verify ACID state; called internally when removing cols/etc.
10244+ // Also called via an unused metastore API that checks for ACID tables.
10245+ MPartition mPartition = getMPartition(catName, dbName, tableName, partName);
10246+ if (mPartition == null) {
10247+ throw new NoSuchObjectException("Partition " + partName
10248+ + " for which stats deletion is requested doesn't exist");
10249+ }
10250+
10251+ return new GetHelper<Boolean>(catName, dbName, tableName, true, true) {
10252+ @Override
10253+ protected String describeResult() {
10254+ return "delete prtition column stats";
10255+ }
10256+
10257+ @Override
10258+ protected Boolean getSqlResult(GetHelper<Boolean> ctx) throws MetaException {
10259+ return directSql.deletePartitionColumnStats(catName, dbName, tableName, partName, colName, engine);
10260+ }
10261+
10262+ @Override
10263+ protected Boolean getJdoResult(GetHelper<Boolean> ctx)
10264+ throws MetaException, NoSuchObjectException, InvalidObjectException {
10265+ return deletePartitionColumnStatisticsVisJDO(catName, dbName, tableName, partName, colName, engine);
10266+ }
10267+ }.run(false);
10268+ }
10269+
10270+ private boolean deletePartitionColumnStatisticsVisJDO(String catName, String dbName, String tableName,
10271+ String partName, String colName, String engine) throws NoSuchObjectException {
10272+ boolean ret = false;
10273+ Query query = null;
1024510274 try {
1024610275 openTransaction();
10247- MTable mTable = getMTable(catName, dbName, tableName);
1024810276 MPartitionColumnStatistics mStatsObj;
1024910277 List<MPartitionColumnStatistics> mStatsObjColl;
10250- if (mTable == null) {
10251- throw new NoSuchObjectException("Table " + tableName
10252- + " for which stats deletion is requested doesn't exist");
10253- }
10254- // Note: this does not verify ACID state; called internally when removing cols/etc.
10255- // Also called via an unused metastore API that checks for ACID tables.
10256- MPartition mPartition = getMPartition(catName, dbName, tableName, partVals, mTable);
10257- if (mPartition == null) {
10258- throw new NoSuchObjectException("Partition " + partName
10259- + " for which stats deletion is requested doesn't exist");
10260- }
1026110278 query = pm.newQuery(MPartitionColumnStatistics.class);
1026210279 String filter;
1026310280 String parameters;
@@ -10334,25 +10351,42 @@ public boolean deletePartitionColumnStatistics(String catName, String dbName, St
1033410351 public boolean deleteTableColumnStatistics(String catName, String dbName, String tableName,
1033510352 String colName, String engine)
1033610353 throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException {
10337- boolean ret = false;
10338- Query query = null;
1033910354 dbName = org.apache.commons.lang3.StringUtils.defaultString(dbName,
1034010355 Warehouse.DEFAULT_DATABASE_NAME);
1034110356 if (tableName == null) {
1034210357 throw new InvalidInputException("Table name is null.");
1034310358 }
10359+
10360+ // Note: this does not verify ACID state; called internally when removing cols/etc.
10361+ // Also called via an unused metastore API that checks for ACID tables.
10362+ return new GetHelper<Boolean>(catName, dbName, tableName, true, true) {
10363+
10364+ @Override
10365+ protected String describeResult() {
10366+ return "delete table column stats";
10367+ }
10368+
10369+ @Override
10370+ protected Boolean getSqlResult(GetHelper<Boolean> ctx) throws MetaException {
10371+ return directSql.deleteTableColumnStatistics(getTable().getId(), colName, engine);
10372+ }
10373+
10374+ @Override
10375+ protected Boolean getJdoResult(GetHelper<Boolean> ctx)
10376+ throws MetaException, NoSuchObjectException, InvalidObjectException {
10377+ return deleteTableColumnStatisticsViaJdo(catName, dbName, tableName, colName, engine);
10378+ }
10379+ }.run(true);
10380+ }
10381+
10382+ private boolean deleteTableColumnStatisticsViaJdo(String catName, String dbName, String tableName,
10383+ String colName, String engine) throws NoSuchObjectException {
10384+ boolean ret = false;
10385+ Query query = null;
1034410386 try {
1034510387 openTransaction();
10346- MTable mTable = getMTable(catName, dbName, tableName);
1034710388 MTableColumnStatistics mStatsObj;
1034810389 List<MTableColumnStatistics> mStatsObjColl;
10349- if (mTable == null) {
10350- throw new NoSuchObjectException("Table " +
10351- TableName.getQualified(catName, dbName, tableName)
10352- + " for which stats deletion is requested doesn't exist");
10353- }
10354- // Note: this does not verify ACID state; called internally when removing cols/etc.
10355- // Also called via an unused metastore API that checks for ACID tables.
1035610390 query = pm.newQuery(MTableColumnStatistics.class);
1035710391 String filter;
1035810392 String parameters;
0 commit comments