private void addPartitions(Table table, List<Partition> partitions, long writeId) throws HiveException {
    List<org.apache.hadoop.hive.ql.metadata.Partition> outPartitions = null;
    if (!desc.getReplicationSpec().isInReplicationScope()) {
      outPartitions = addPartitionsNoReplication(table, partitions);
    } else {
      outPartitions = addPartitionsWithReplication(table, partitions, writeId);
    }

    for (org.apache.hadoop.hive.ql.metadata.Partition outPartition : outPartitions) {
      DDLUtils.addIfAbsentByName(new WriteEntity(outPartition, WriteEntity.WriteType.INSERT), context);
    }
  }
Operation process of adding a partition to a table.
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/partition/add/AlterTableAddPartitionOperation.java