diff --git ql/src/java/org/apache/hadoop/hive/ql/Context.java ql/src/java/org/apache/hadoop/hive/ql/Context.java index 7b861ed..5b62f93 100644 --- ql/src/java/org/apache/hadoop/hive/ql/Context.java +++ ql/src/java/org/apache/hadoop/hive/ql/Context.java @@ -364,6 +364,12 @@ public String getExternalTmpFileURI(URI extURI) { nextPathId(); } + public String getExternalTmpLocRelTo(URI extURI) { + return getScratchDir(extURI.getScheme(), extURI.getAuthority(), !explain, + extURI.getPath()+ Path.SEPARATOR + "_" + this.executionId) + + Path.SEPARATOR + EXT_PREFIX +nextPathId(); + } + /** * @return the resFile */ diff --git ql/src/java/org/apache/hadoop/hive/ql/optimizer/GenMapRedUtils.java ql/src/java/org/apache/hadoop/hive/ql/optimizer/GenMapRedUtils.java index 1e89fcd..3e0cc57 100644 --- ql/src/java/org/apache/hadoop/hive/ql/optimizer/GenMapRedUtils.java +++ ql/src/java/org/apache/hadoop/hive/ql/optimizer/GenMapRedUtils.java @@ -1677,7 +1677,7 @@ public static Path createMoveTask(Task currTask, boolean // generate the temporary file // it must be on the same file system as the current destination Context baseCtx = parseCtx.getContext(); - String tmpDir = baseCtx.getExternalTmpFileURI(dest.toUri()); + String tmpDir = baseCtx.getExternalTmpLocRelTo(dest.toUri()); FileSinkDesc fileSinkDesc = fsOp.getConf(); // Change all the linked file sink descriptors diff --git ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java index 848e0ab..8409db2 100644 --- ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java +++ ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java @@ -5332,7 +5332,7 @@ private Operator genFileSinkPlan(String dest, QB qb, Operator input) if (isNonNativeTable) { queryTmpdir = dest_path.toUri().getPath(); } else { - queryTmpdir = ctx.getExternalTmpFileURI(dest_path.toUri()); + queryTmpdir = ctx.getExternalTmpLocRelTo(dest_path.getParent().toUri()); } if (dpCtx != null) { // set the root of the temporay path where dynamic partition columns will populate @@ -5425,7 +5425,7 @@ private Operator genFileSinkPlan(String dest, QB qb, Operator input) dest_path = new Path(tabPath.toUri().getScheme(), tabPath.toUri() .getAuthority(), partPath.toUri().getPath()); - queryTmpdir = ctx.getExternalTmpFileURI(dest_path.toUri()); + queryTmpdir = ctx.getExternalTmpLocRelTo(dest_path.getParent().toUri()); table_desc = Utilities.getTableDesc(dest_tab); // Add sorting/bucketing if needed