You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by da...@apache.org on 2018/10/25 18:08:41 UTC

hive git commit: HIVE-18778: Needs to capture input/output entities in explain (Daniel Dai, reviewed by Thejas Nair)

Repository: hive
Updated Branches:
  refs/heads/branch-2 55fcff151 -> 0083145ef


HIVE-18778: Needs to capture input/output entities in explain (Daniel Dai, reviewed by Thejas Nair)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/0083145e
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/0083145e
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/0083145e

Branch: refs/heads/branch-2
Commit: 0083145ef6eb85b81ce30ff723a157804748763d
Parents: 55fcff1
Author: Daniel Dai <da...@gmail.com>
Authored: Thu Oct 25 11:08:10 2018 -0700
Committer: Daniel Dai <da...@gmail.com>
Committed: Thu Oct 25 11:08:10 2018 -0700

----------------------------------------------------------------------
 .../apache/hadoop/hive/ql/hooks/EnforceReadOnlyTables.java    | 7 ++++---
 .../apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java  | 4 ++++
 2 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/0083145e/ql/src/java/org/apache/hadoop/hive/ql/hooks/EnforceReadOnlyTables.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/hooks/EnforceReadOnlyTables.java b/ql/src/java/org/apache/hadoop/hive/ql/hooks/EnforceReadOnlyTables.java
index 4569ed5..895ce89 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/hooks/EnforceReadOnlyTables.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/hooks/EnforceReadOnlyTables.java
@@ -53,11 +53,12 @@ public class EnforceReadOnlyTables implements ExecuteWithHookContext {
     Set<ReadEntity> inputs = hookContext.getInputs();
     Set<WriteEntity> outputs = hookContext.getOutputs();
     UserGroupInformation ugi = hookContext.getUgi();
-    this.run(ss,inputs,outputs,ugi);
+    boolean isExplain = hookContext.getQueryPlan().isExplain();
+    this.run(ss,inputs,outputs,ugi, isExplain);
   }
 
   public void run(SessionState sess, Set<ReadEntity> inputs,
-      Set<WriteEntity> outputs, UserGroupInformation ugi)
+      Set<WriteEntity> outputs, UserGroupInformation ugi, boolean isExplain)
     throws Exception {
 
     // Don't enforce during test driver setup or shutdown.
@@ -70,7 +71,7 @@ public class EnforceReadOnlyTables implements ExecuteWithHookContext {
           (w.getTyp() == WriteEntity.Type.PARTITION)) {
         Table t = w.getTable();
         if (DEFAULT_DATABASE_NAME.equalsIgnoreCase(t.getDbName())
-            && READ_ONLY_TABLES.contains(t.getTableName())) {
+            && READ_ONLY_TABLES.contains(t.getTableName())  && !isExplain) {
           throw new RuntimeException ("Cannot overwrite read-only table: " + t.getTableName());
         }
       }

http://git-wip-us.apache.org/repos/asf/hive/blob/0083145e/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java
index f62cf9a..4af04c3 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java
@@ -164,6 +164,10 @@ public class ExplainSemanticAnalyzer extends BaseSemanticAnalyzer {
     BaseSemanticAnalyzer sem = SemanticAnalyzerFactory.get(queryState, input);
     sem.analyze(input, ctx);
     sem.validate();
+    if (!HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_IN_TEST, false)) {
+      inputs = sem.getInputs();
+      outputs = sem.getOutputs();
+    }
 
     ctx.setResFile(ctx.getLocalTmpPath());
     List<Task<? extends Serializable>> tasks = sem.getAllRootTasks();