Source:
private Task<?> loadTableTask(Table table, ReplicationSpec replicationSpec, Path tgtPath, Path fromURI) { Path dataPath = new Path(fromURI, EximUtil.DATA_PATH_NAME); Path tmpPath = tgtPath; LoadFileType loadFileType; if (replicationSpec.isInReplicationScope() && !replicationSpec.isDoingMigration() && context.hiveConf.getBoolVar(REPL_ENABLE_MOVE_OPTIMIZATION)) { loadFileType = LoadFileType.IGNORE; } else { loadFileType = replicationSpec.isReplace() ? LoadFileType.REPLACE_ALL : replicationSpec.isDoingMigration() ? LoadFileType.KEEP_EXISTING : LoadFileType.OVERWRITE_EXISTING; tmpPath = PathUtils.getExternalTmpPath(tgtPath, context.pathInfo); } LOG.debug("adding dependent CopyWork/AddPart/MoveWork for table " + table.getCompleteName() + " with source location: " + dataPath.toString() + " and target location " + tgtPath.toString()); Task<?> copyTask = ReplCopyTask.getLoadCopyTask(replicationSpec, dataPath, tmpPath, context.hiveConf, false, false); MoveWork moveWork = new MoveWork(new HashSet<>(), new HashSet<>(), null, null, false); if (AcidUtils.isTransactionalTable(table)) { if (replicationSpec.isDoingMigration()) { LoadTableDesc loadTableWork = new LoadTableDesc( tmpPath, Utilities.getTableDesc(table), new TreeMap<>(), loadFileType, 1L ); moveWork.setLoadTableWork(loadTableWork); } else { LoadMultiFilesDesc loadFilesWork = new LoadMultiFilesDesc( Collections.singletonList(tmpPath), Collections.singletonList(tgtPath), true, null, null); moveWork.setMultiFilesDesc(loadFilesWork); } } else { LoadTableDesc loadTableWork = new LoadTableDesc( tmpPath, Utilities.getTableDesc(table), new TreeMap<>(), loadFileType, 0L ); moveWork.setLoadTableWork(loadTableWork); } Task<?> loadTableTask = TaskFactory.get(moveWork, context.hiveConf); copyTask.addDependentTask(loadTableTask); return copyTask; }

Target:
private Task<?> loadTableTask(Table table, ReplicationSpec replicationSpec, Path tgtPath, Path fromURI) { Path dataPath = new Path(fromURI, EximUtil.DATA_PATH_NAME); Path tmpPath = tgtPath; LoadFileType loadFileType; if (replicationSpec.isInReplicationScope() && !replicationSpec.isMigratingToTxnTable() && context.hiveConf.getBoolVar(REPL_ENABLE_MOVE_OPTIMIZATION)) { loadFileType = LoadFileType.IGNORE; } else { loadFileType = replicationSpec.isReplace() ? LoadFileType.REPLACE_ALL : replicationSpec.isMigratingToTxnTable() ? LoadFileType.KEEP_EXISTING : LoadFileType.OVERWRITE_EXISTING; tmpPath = PathUtils.getExternalTmpPath(tgtPath, context.pathInfo); } LOG.debug("adding dependent CopyWork/AddPart/MoveWork for table " + table.getCompleteName() + " with source location: " + dataPath.toString() + " and target location " + tgtPath.toString()); Task<?> copyTask = ReplCopyTask.getLoadCopyTask(replicationSpec, dataPath, tmpPath, context.hiveConf, false, false); MoveWork moveWork = new MoveWork(new HashSet<>(), new HashSet<>(), null, null, false); if (AcidUtils.isTransactionalTable(table)) { if (replicationSpec.isMigratingToTxnTable()) { LoadTableDesc loadTableWork = new LoadTableDesc( tmpPath, Utilities.getTableDesc(table), new TreeMap<>(), loadFileType, 1L ); moveWork.setLoadTableWork(loadTableWork); } else { LoadMultiFilesDesc loadFilesWork = new LoadMultiFilesDesc( Collections.singletonList(tmpPath), Collections.singletonList(tgtPath), true, null, null); moveWork.setMultiFilesDesc(loadFilesWork); } } else { LoadTableDesc loadTableWork = new LoadTableDesc( tmpPath, Utilities.getTableDesc(table), new TreeMap<>(), loadFileType, 0L ); moveWork.setLoadTableWork(loadTableWork); } Task<?> loadTableTask = TaskFactory.get(moveWork, context.hiveConf); copyTask.addDependentTask(loadTableTask); return copyTask; }