private CreateFunctionDesc build() throws SemanticException {
      replCopyTasks.clear();
      PrimaryToReplicaResourceFunction conversionFunction =
          new PrimaryToReplicaResourceFunction(context, metadata, destinationDbName);
      // We explicitly create immutable lists here as it forces the guava lib to run the transformations
      // and not do them lazily. The reason being the function class used for transformations additionally
      // also creates the corresponding replCopyTasks, which cannot be evaluated lazily. since the query
      // plan needs to be complete before we execute and not modify it while execution in the driver.
      List<ResourceUri> transformedUris = (metadata.function.getResourceUris() == null)
              ? null
              : ImmutableList.copyOf(Lists.transform(metadata.function.getResourceUris(), conversionFunction));
      replCopyTasks.addAll(conversionFunction.replCopyTasks);
      String fullQualifiedFunctionName = FunctionUtils.qualifyFunctionName(
          metadata.function.getFunctionName(), destinationDbName
      );
      // For bootstrap load, the create function should be always performed.
      // Only for incremental load, need to validate if event is newer than the database.
      ReplicationSpec replSpec = (context.dmd == null) ? null : context.eventOnlyReplicationSpec();
      return new CreateFunctionDesc(
              fullQualifiedFunctionName, metadata.function.getClassName(), false,
              transformedUris, replSpec
      );
    }
This is to understand how task dependencies work.
 All root tasks are executed in parallel. For bootstrap replication there should be only one root task of creating db. Incremental can be multiple ( have to verify ).
 Task has children, which are put in queue for execution after the parent has finished execution.
 One -to- One dependency can be satisfied by adding children to a given task, do this recursively where the relation holds.
 for many to one , create a barrier task that is the child of every item in 'many' dependencies, make the 'one' dependency as child of barrier task.
 add the 'many' to parent/root tasks. The execution environment will make sure that the child barrier task will not get executed unless all parents of the barrier task are complete,
 which should only happen when the last task is finished, at which point the child of the barrier task is picked up.
ql/src/java/org/apache/hadoop/hive/ql/parse/repl/load/message/CreateFunctionHandler.java