private boolean addTasksForPartition(Table table, AlterTableAddPartitionDesc addPartitionDesc,
                                    AlterTableAddPartitionDesc.PartitionDesc lastPartSpec)
          throws MetaException, HiveException {
    Task<?> addPartTask = TaskFactory.get(
      new DDLWork(new HashSet<>(), new HashSet<>(), addPartitionDesc,
              true, (new Path(context.dumpDirectory)).getParent().toString(), this.metricCollector),
      context.hiveConf
    );
    //checkpointing task already added as part of add batch of partition
    if (isMetaDataOp() || TableType.EXTERNAL_TABLE.equals(table.getTableType())) {
      tracker.addTask(addPartTask);
      return true;
    }
    //Add Copy task for all partitions
    boolean lastProcessedStageFound = false;
    for (AlterTableAddPartitionDesc.PartitionDesc partSpec : addPartitionDesc.getPartitions()) {
      if (!tracker.canAddMoreTasks()) {
        //update replication state with the copy task added with which it needs to proceed next
        ReplicationState currentReplicationState =
          new ReplicationState(new PartitionState(table.getTableName(), addPartitionDesc,
            partSpec, PartitionState.Stage.COPY));
        updateReplicationState(currentReplicationState);
        return false;
      }
      Path replicaWarehousePartitionLocation = locationOnReplicaWarehouse(table, partSpec);
      partSpec.setLocation(replicaWarehousePartitionLocation.toString());
      LOG.debug("adding dependent CopyWork for partition "
        + partSpecToString(partSpec.getPartSpec()) + " with source location: "
        + partSpec.getLocation());
      if (!lastProcessedStageFound && lastPartSpec != null &&
        lastPartSpec.getLocation() != partSpec.getLocation()) {
        //Don't process copy task if already processed as part of previous run
        continue;
      }
      lastProcessedStageFound = true;
      boolean copyAtLoad = context.hiveConf.getBoolVar(HiveConf.ConfVars.REPL_RUN_DATA_COPY_TASKS_ON_TARGET);
      Task<?> copyTask = ReplCopyTask.getLoadCopyTask(
        event.replicationSpec(),
        new Path(event.dataPath() + Path.SEPARATOR + Warehouse.makePartPath(partSpec.getPartSpec())),
        replicaWarehousePartitionLocation,
        context.hiveConf, copyAtLoad, false, (new Path(context.dumpDirectory)).getParent().toString(),
        this.metricCollector
      );
      tracker.addTask(copyTask);
    }
    //add partition metadata task once all the copy tasks are added
    tracker.addDependentTask(addPartTask);
    return true;
  }
returns the root task for adding all partitions in a batch
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/bootstrap/load/table/LoadPartitions.java