void findUnknownPartitions(Table table, Set<Path> missingPartDirs,
      CheckResult result) throws IOException, MetastoreException, MetaException {

    Path tablePath = getPath(table);
    if (tablePath == null) {
      return;
    }
    boolean transactionalTable = TxnUtils.isTransactionalTable(table);

    Set<String> partColNames = Sets.newHashSet();
    for(FieldSchema fSchema : getPartCols(table)) {
      partColNames.add(fSchema.getName());
    }

    Map<String, String> partitionColToTypeMap = getPartitionColtoTypeMap(table.getPartitionKeys());
    // we should now only have the unexpected folders left
    for (Path partPath : missingPartDirs) {
      FileSystem fs = partPath.getFileSystem(conf);
      String partitionName = getPartitionName(fs.makeQualified(tablePath),
          partPath, partColNames, partitionColToTypeMap);
      LOG.debug("PartitionName: " + partitionName);

      if (partitionName != null) {
        CheckResult.PartitionResult pr = new CheckResult.PartitionResult();
        pr.setPartitionName(partitionName);
        pr.setTableName(table.getTableName());
        // Also set the correct partition path here as creating path from Warehouse.makePartPath will always return
        // lowercase keys/path. Even if we add the new partition with lowerkeys, get queries on such partition
        // will not return any results.
        pr.setPath(partPath);

        // Check if partition already exists. No need to check for those partition which are present in db
        // but no in fs as msck will override the partition location in db
        if (result.getCorrectPartitions().contains(pr)) {
          String msg = "The partition '" + pr.toString() + "' already exists for table" + table.getTableName();
          throw new MetastoreException(msg);
        } else if (result.getPartitionsNotInMs().contains(pr)) {
          String msg = "Found two paths for same partition '" + pr.toString() + "' for table " + table.getTableName();
          throw new MetastoreException(msg);
        }
        if (transactionalTable) {
          setMaxTxnAndWriteIdFromPartition(partPath, pr);
        }
        result.getPartitionsNotInMs().add(pr);
        if (result.getPartitionsNotOnFs().contains(pr)) {
          result.getPartitionsNotOnFs().remove(pr);
        }
      }
    }
    LOG.debug("Number of partitions not in metastore : " + result.getPartitionsNotInMs().size());
  }
Add partitions on the fs that are unknown to the metastore.

@param table
         Table where the partitions would be located
@param missingPartDirs
         Paths of the partitions that ms does not know about
@param result
         Result object
@throws IOException
          Thrown if we fail at fetching listings from the fs.
@throws MetastoreException ex
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreChecker.java