public static Path createMoveTask(Task<?> currTask, boolean chDir,
      FileSinkOperator fsOp, ParseContext parseCtx, List<Task<MoveWork>> mvTasks,
      HiveConf hconf, DependencyCollectionTask dependencyTask) {

    Path dest = null;

    FileSinkDesc fileSinkDesc = fsOp.getConf();
    boolean isMmTable = fileSinkDesc.isMmTable();
    boolean isDirectInsert = fileSinkDesc.isDirectInsert();
    if (chDir) {
      dest = fileSinkDesc.getMergeInputDirName();
      /**
       * Skip temporary file generation for:
       * 1. MM Tables
       * 2. INSERT operation on full ACID table
       */
      if (!isMmTable && !isDirectInsert) {
        Context baseCtx = parseCtx.getContext();

        // Choose location of required temporary file
        Path tmpDir = null;
        if (hconf.getBoolVar(ConfVars.HIVE_USE_SCRATCHDIR_FOR_STAGING)) {
          tmpDir = baseCtx.getTempDirForInterimJobPath(fileSinkDesc.getDestPath());
        } else {
          tmpDir = baseCtx.getTempDirForFinalJobPath(fileSinkDesc.getDestPath());
        }
        DynamicPartitionCtx dpCtx = fileSinkDesc.getDynPartCtx();
        if (dpCtx != null && dpCtx.getSPPath() != null) {
          tmpDir = new Path(tmpDir, dpCtx.getSPPath());
        }

        // Change all the linked file sink descriptors
        if (fileSinkDesc.isLinkedFileSink()) {
          for (FileSinkDesc fsConf : fileSinkDesc.getLinkedFileSinkDesc()) {
            fsConf.setDirName(new Path(tmpDir, fsConf.getDirName().getName()));
            if (Utilities.FILE_OP_LOGGER.isTraceEnabled()) {
              Utilities.FILE_OP_LOGGER.trace("createMoveTask setting tmpDir for LinkedFileSink chDir "
                + fsConf.getDirName() + "; dest was " + fileSinkDesc.getDestPath());
            }
          }
        } else {
          fileSinkDesc.setDirName(tmpDir);
          if (Utilities.FILE_OP_LOGGER.isTraceEnabled()) {
            Utilities.FILE_OP_LOGGER.trace("createMoveTask setting tmpDir chDir "
              + tmpDir + "; dest was " + fileSinkDesc.getDestPath());
          }
        }
      }
    }

    Task<MoveWork> mvTask = null;

    if (!chDir) {
      mvTask = GenMapRedUtils.findMoveTaskForFsopOutput(mvTasks, fsOp.getConf().getFinalDirName(), isMmTable,
          isDirectInsert, fsOp.getConf().getMoveTaskId(), fsOp.getConf().getAcidOperation());
    }

    // Set the move task to be dependent on the current task
    if (mvTask != null) {
      GenMapRedUtils.addDependentMoveTasks(mvTask, hconf, currTask, dependencyTask);
    }

    return dest;
  }
Create and add any dependent move tasks

@param currTask
@param chDir
@param fsOp
@param parseCtx
@param mvTasks
@param hconf
@param dependencyTask
@return
ql/src/java/org/apache/hadoop/hive/ql/optimizer/GenMapRedUtils.java