Index: ql/src/test/results/clientpositive/list_bucket_dml_10.q.out =================================================================== --- ql/src/test/results/clientpositive/list_bucket_dml_10.q.out (revision 1557173) +++ ql/src/test/results/clientpositive/list_bucket_dml_10.q.out (working copy) @@ -230,7 +230,7 @@ name: default.list_bucketing_static_part name: default.list_bucketing_static_part Truncated Path -> Alias: -#### A masked pattern was here #### + /list_bucketing_static_part/ds=2008-04-08/_hive_2014-01-10_08-30-52_403_4447446487309903428-1/-ext-10001 [] Stage: Stage-5 Block level merge @@ -269,7 +269,7 @@ name: default.list_bucketing_static_part name: default.list_bucketing_static_part Truncated Path -> Alias: -#### A masked pattern was here #### + /list_bucketing_static_part/ds=2008-04-08/_hive_2014-01-10_08-30-52_403_4447446487309903428-1/-ext-10001 [] Stage: Stage-6 Move Operator Index: ql/src/java/org/apache/hadoop/hive/ql/optimizer/GenMapRedUtils.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/optimizer/GenMapRedUtils.java (revision 1557174) +++ ql/src/java/org/apache/hadoop/hive/ql/optimizer/GenMapRedUtils.java (working copy) @@ -1692,7 +1692,7 @@ // generate the temporary file // it must be on the same file system as the current destination Context baseCtx = parseCtx.getContext(); - Path tmpDir = baseCtx.getExternalTmpPath(dest.toUri()); + Path tmpDir = baseCtx.getExtTmpPathRelTo(dest.toUri()); FileSinkDesc fileSinkDesc = fsOp.getConf(); // Change all the linked file sink descriptors Index: ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (revision 1557174) +++ ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (working copy) @@ -5332,7 +5332,7 @@ if (isNonNativeTable) { queryTmpdir = dest_path; } else { - queryTmpdir = ctx.getExternalTmpPath(dest_path.toUri()); + queryTmpdir = ctx.getExtTmpPathRelTo(dest_path.getParent().toUri()); } if (dpCtx != null) { // set the root of the temporay path where dynamic partition columns will populate @@ -5425,7 +5425,7 @@ dest_path = new Path(tabPath.toUri().getScheme(), tabPath.toUri() .getAuthority(), partPath.toUri().getPath()); - queryTmpdir = ctx.getExternalTmpPath(dest_path.toUri()); + queryTmpdir = ctx.getExtTmpPathRelTo(dest_path.getParent().toUri()); table_desc = Utilities.getTableDesc(dest_tab); // Add sorting/bucketing if needed Index: ql/src/java/org/apache/hadoop/hive/ql/Context.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/Context.java (revision 1557174) +++ ql/src/java/org/apache/hadoop/hive/ql/Context.java (working copy) @@ -364,6 +364,11 @@ nextPathId()); } + public Path getExtTmpPathRelTo(URI uri) { + return new Path (getScratchDir(uri.getScheme(), uri.getAuthority(), !explain, + uri.getPath() + Path.SEPARATOR + "_" + this.executionId), EXT_PREFIX + nextPathId()); + } + /** * @return the resFile */