You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by go...@apache.org on 2020/03/30 06:26:32 UTC
[hive] branch master updated: HIVE-22948: QueryCache: Treat query
cache locations as temporary storage (Gopal V, reviewed by Vineet Garg)
This is an automated email from the ASF dual-hosted git repository.
gopalv pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new 5dda1b1 HIVE-22948: QueryCache: Treat query cache locations as temporary storage (Gopal V, reviewed by Vineet Garg)
5dda1b1 is described below
commit 5dda1b1ae283493eea2387843cc35440363dfce3
Author: Gopal V <go...@apache.org>
AuthorDate: Sun Mar 29 23:26:18 2020 -0700
HIVE-22948: QueryCache: Treat query cache locations as temporary storage (Gopal V, reviewed by Vineet Garg)
Signed-off-by: Gopal V <go...@apache.org>
---
.../plugin/TestHiveAuthorizerCheckInvocation.java | 14 ++++++++++++++
ql/src/java/org/apache/hadoop/hive/ql/Context.java | 16 ++++++++++++++++
.../apache/hadoop/hive/ql/parse/SemanticAnalyzer.java | 4 +++-
3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/authorization/plugin/TestHiveAuthorizerCheckInvocation.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/authorization/plugin/TestHiveAuthorizerCheckInvocation.java
index 09d142a..37bb6ad 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/authorization/plugin/TestHiveAuthorizerCheckInvocation.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/authorization/plugin/TestHiveAuthorizerCheckInvocation.java
@@ -98,6 +98,7 @@ public class TestHiveAuthorizerCheckInvocation {
conf.setBoolVar(ConfVars.HIVE_SERVER2_ENABLE_DOAS, false);
conf.setBoolVar(ConfVars.HIVE_SUPPORT_CONCURRENCY, true);
conf.setVar(ConfVars.HIVE_TXN_MANAGER, DbTxnManager.class.getName());
+ conf.setBoolVar(ConfVars.HIVE_QUERY_RESULTS_CACHE_ENABLED, true);
conf.setVar(HiveConf.ConfVars.HIVEMAPREDMODE, "nonstrict");
SessionState.start(conf);
@@ -161,6 +162,19 @@ public class TestHiveAuthorizerCheckInvocation {
}
@Test
+ public void testQueryCacheIgnored() throws Exception {
+
+ reset(mockedAuthorizer);
+ int status = driver.compile("select i from " + acidTableName
+ + " where i > 0 ", true);
+ assertEquals(0, status);
+ List<HivePrivilegeObject> outputs = getHivePrivilegeObjectInputs().getRight();
+ List<HivePrivilegeObject> inputs = getHivePrivilegeObjectInputs().getLeft();
+ assertEquals("No outputs for a select", 0, outputs.size());
+ assertEquals("One input for this select", 1, inputs.size());
+ }
+
+ @Test
public void testInputSomeColumnsUsedJoin() throws Exception {
reset(mockedAuthorizer);
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 a85b94c..fd627c6 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/Context.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/Context.java
@@ -727,6 +727,22 @@ public class Context {
(uriStr.indexOf(MR_PREFIX) != -1);
}
+ /**
+ * Check if the path is a result cache dir for this query. This doesn't work unless the result
+ * paths have already been set in SemanticAnalyzer::getDestinationFilePath to prevent someone from
+ * overriding LOCATION in a create table command to overwrite cached results
+ *
+ * @param destinationPath
+ * @return true if the path is a result cache dir
+ */
+
+ public boolean isResultCacheDir(Path destinationPath) {
+ if (this.fsResultCacheDirs != null) {
+ return this.fsResultCacheDirs.equals(destinationPath);
+ }
+ return false;
+ }
+
public Path getMRTmpPath(URI uri) {
return new Path(getStagingDir(new Path(uri), !isExplainSkipExecution()), MR_PREFIX + nextPathId());
}
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 679ae2e..98317d1 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
@@ -7767,7 +7767,9 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
}
boolean isDestTempFile = true;
- if (!ctx.isMRTmpFileURI(destinationPath.toUri().toString())) {
+ if (ctx.isMRTmpFileURI(destinationPath.toUri().toString()) == false
+ && ctx.isResultCacheDir(destinationPath) == false) {
+ // not a temp dir and not a result cache dir
idToTableNameMap.put(String.valueOf(destTableId), destinationPath.toUri().toString());
currentTableId = destTableId;
destTableId++;