@@ -8468,6 +8468,7 @@ private FileSinkDesc createFileSinkDesc(String dest, TableDesc table_desc,
84688468 RowSchema fsRS, boolean canBeMerged, Table dest_tab, boolean isMmCtas,
84698469 Integer dest_type, QB qb, boolean isDirectInsert, AcidUtils.Operation acidOperation, String moveTaskId) throws SemanticException {
84708470 boolean isInsertOverwrite = false;
8471+ boolean isLocal = false;
84718472 Context.Operation writeOperation = getWriteOperation(dest);
84728473 switch (dest_type) {
84738474 case QBMetaData.DEST_PARTITION:
@@ -8492,6 +8493,7 @@ private FileSinkDesc createFileSinkDesc(String dest, TableDesc table_desc,
84928493
84938494 break;
84948495 case QBMetaData.DEST_LOCAL_FILE:
8496+ isLocal = true;
84958497 case QBMetaData.DEST_DFS_FILE:
84968498 //CTAS path or insert into file/directory
84978499 break;
@@ -8545,7 +8547,12 @@ private FileSinkDesc createFileSinkDesc(String dest, TableDesc table_desc,
85458547 fileSinkDesc.setStatsAggPrefix(fileSinkDesc.getDirName().toString());
85468548 if (!destTableIsMaterialization &&
85478549 HiveConf.getVar(conf, HIVE_STATS_DBCLASS).equalsIgnoreCase(StatDB.fs.name())) {
8548- String statsTmpLoc = ctx.getTempDirForInterimJobPath(dest_path).toString();
8550+ String statsTmpLoc;
8551+ if (isLocal){
8552+ statsTmpLoc = ctx.getMRTmpPath().toString();
8553+ } else {
8554+ statsTmpLoc = ctx.getTempDirForInterimJobPath(dest_path).toString();
8555+ }
85498556 fileSinkDesc.setStatsTmpDir(statsTmpLoc);
85508557 LOG.debug("Set stats collection dir : " + statsTmpLoc);
85518558 }
0 commit comments