List<Partition> addPartitions(List<Partition> partitions, boolean ifNotExists)
      throws MetaException, AlreadyExistsException {
    List<Partition> partitionsAdded = new ArrayList<>();
    Map<String, Partition> partNameToPartition = new HashMap<>();
    // validate that the new partition values is not already added to the table
    for (Partition partition : partitions) {
      String partName = makePartName(tTable.getPartitionKeys(), partition.getValues());
      if (!ifNotExists && parts.containsKey(partName)) {
        throw new AlreadyExistsException("Partition " + partName + " already exists");
      }
      partNameToPartition.put(partName, partition);
    }

    for (Map.Entry<String, Partition> entry : partNameToPartition.entrySet()) {
      if (addPartition(entry.getValue(), entry.getKey(), ifNotExists) == null) {
        partitionsAdded.add(entry.getValue());
      }
    }

    return partitionsAdded;
  }
Add partitions to the partition tree.

@param partitions  The partitions to add
@param ifNotExists only add partitions if they don't exist
@return the partitions that were added
@throws MetaException partition metadata is incorrect
@throws AlreadyExistsException if the partition with the same name already exists.
ql/src/java/org/apache/hadoop/hive/ql/metadata/PartitionTree.java