diff --git a/ql/src/java/org/apache/hadoop/hive/ql/Context.java b/ql/src/java/org/apache/hadoop/hive/ql/Context.java index 18089d59fd..1eac7d786f 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/Context.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/Context.java @@ -532,14 +532,14 @@ public Path getLocalScratchDir(boolean mkdir) { /** * Create a map-reduce scratch directory on demand and return it. + * @param mkDir flag to indicate if scratch dir is to be created or not * */ - public Path getMRScratchDir() { - + public Path getMRScratchDir(boolean mkDir) { // if we are executing entirely on the client side - then // just (re)use the local scratch directory if(isLocalOnlyExecutionMode()) { - return getLocalScratchDir(!isExplainSkipExecution()); + return getLocalScratchDir(mkDir); } try { @@ -547,16 +547,23 @@ public Path getMRScratchDir() { URI uri = dir.toUri(); Path newScratchDir = getScratchDir(uri.getScheme(), uri.getAuthority(), - !isExplainSkipExecution(), uri.getPath()); + mkDir, uri.getPath()); LOG.info("New scratch dir is " + newScratchDir); return newScratchDir; } catch (IOException e) { throw new RuntimeException(e); } catch (IllegalArgumentException e) { throw new RuntimeException("Error while making MR scratch " - + "directory - check filesystem config (" + e.getCause() + ")", e); + + "directory - check filesystem config (" + e.getCause() + ")", e); } } + /** + * Create a map-reduce scratch directory on demand and return it. + * + */ + public Path getMRScratchDir() { + return getMRScratchDir(!isExplainSkipExecution()); + } /** * Create a temporary directory depending of the path specified. @@ -675,6 +682,10 @@ public Path getMRTmpPath(URI uri) { return new Path(getStagingDir(new Path(uri), !isExplainSkipExecution()), MR_PREFIX + nextPathId()); } + public Path getMRTmpPath(boolean mkDir) { + return new Path(getMRScratchDir(mkDir), MR_PREFIX + + nextPathId()); + } /** * Get a path to store map-reduce intermediate data in. * diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java index adce54cf27..b47a18bd2f 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java @@ -2545,7 +2545,7 @@ private Path getStagingDirectoryPathname(QB qb) throws HiveException { stagingPath = ctx.getMRTmpPath(tablePath.toUri()); } } else { - stagingPath = ctx.getMRTmpPath(); + stagingPath = ctx.getMRTmpPath(false); } return stagingPath;