@Override
      protected Integer getJdoResult(GetHelper<Integer> ctx)
          throws MetaException, NoSuchObjectException, InvalidObjectException {
        // size is known since it contains dbName, catName, tblName and partialRegex pattern
        Map<String, String> params = new HashMap<>(4);
        String filter = getJDOFilterStrForPartitionVals(ctx.getTable(), partVals, params);
        try (QueryWrapper query = new QueryWrapper(pm.newQuery(
            "select count(partitionName) from org.apache.hadoop.hive.metastore.model.MPartition"))) {
          query.setFilter(filter);
          query.declareParameters(makeParameterDeclarationString(params));
          Long result = (Long) query.executeWithMap(params);

          return result.intValue();
        }
      }
Drop an MPartition and cascade deletes (e.g., delete partition privilege grants,
  drop the storage descriptor cleanly, etc.)
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java