abstractdog commented on code in PR #6376:
URL: https://github.com/apache/hive/pull/6376#discussion_r3079810687


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java:
##########
@@ -7500,19 +7500,24 @@ protected Table getTargetTable(QB qb, String dest) 
throws SemanticException {
   }
 
   private Path getDestinationFilePath(QB qb, final String destinationFile, 
boolean isMmTable) {
+    Path defaultPath = new Path(destinationFile);
     if (this.isResultsCacheEnabled() && this.queryTypeCanUseCache(qb)) {
       assert (!isMmTable);
       QueryResultsCache instance = QueryResultsCache.getInstance();
       // QueryResultsCache should have been initialized by now
       if (instance != null) {
-        Path resultCacheTopDir = instance.getCacheDirPath();
-        String dirName = UUID.randomUUID().toString();
-        Path resultDir = new Path(resultCacheTopDir, dirName);
-        this.ctx.setFsResultCacheDirs(resultDir);
-        return resultDir;
+        if 
(!conf.getBoolVar(ConfVars.HIVE_QUERY_RESULTS_SAFE_CACHE_WRITE_ENABLED)) {
+          Path resultCacheTopDir = instance.getCacheDirPath();
+          String dirName = UUID.randomUUID().toString();
+          Path resultDir = new Path(resultCacheTopDir, dirName);
+          this.ctx.setFsResultCacheDirs(resultDir);
+          return resultDir;
+        } else {
+          instance.setSafeDir(defaultPath.toString());

Review Comment:
   this is true, `QueryResultsCache instance` is a global singleton, using it 
like this can mess up things



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to