hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aihu...@apache.org
Subject hive git commit: HIVE-17831: HiveSemanticAnalyzerHookContext does not update the HiveOperation after sem.analyze() is called (Aihua Xu, reviewed by Sergio Pena)
Date Fri, 20 Oct 2017 16:55:39 GMT
Repository: hive
Updated Branches:
  refs/heads/branch-2.2 fbbffda3a -> 43d8647fd


HIVE-17831: HiveSemanticAnalyzerHookContext does not update the HiveOperation after sem.analyze()
is called (Aihua Xu, reviewed by Sergio Pena)


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

Branch: refs/heads/branch-2.2
Commit: 43d8647fd0dbe350638478a7f9e8415cead813d2
Parents: fbbffda
Author: Aihua Xu <aihuaxu@apache.org>
Authored: Wed Oct 18 17:01:20 2017 -0700
Committer: Aihua Xu <aihuaxu@apache.org>
Committed: Fri Oct 20 09:55:02 2017 -0700

----------------------------------------------------------------------
 .../apache/hadoop/hive/hooks/TestHs2Hooks.java  | 36 ++++++++++++++++++++
 .../HiveSemanticAnalyzerHookContextImpl.java    |  1 +
 2 files changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/43d8647f/itests/hive-unit/src/test/java/org/apache/hadoop/hive/hooks/TestHs2Hooks.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/hooks/TestHs2Hooks.java
b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/hooks/TestHs2Hooks.java
index dad516c..7f2517b 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/hooks/TestHs2Hooks.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/hooks/TestHs2Hooks.java
@@ -187,6 +187,7 @@ public class TestHs2Hooks {
     Properties connProp = new Properties();
     connProp.setProperty("user", System.getProperty("user.name"));
     connProp.setProperty("password", "");
+
     HiveConnection connection = new HiveConnection("jdbc:hive2://localhost:10000/default",
connProp);
     Statement stmt = connection.createStatement();
     stmt.executeQuery("show databases");
@@ -234,5 +235,40 @@ public class TestHs2Hooks {
     Assert.assertTrue(SemanticAnalysisHook.ipAddress,
         SemanticAnalysisHook.ipAddress.contains("127.0.0.1"));
     Assert.assertEquals("show tables", SemanticAnalysisHook.command);
+
+    stmt.close();
+    connection.close();
+  }
+
+  @Test
+  public void testPostAnalysisHookContexts() throws Throwable {
+    Properties connProp = new Properties();
+    connProp.setProperty("user", System.getProperty("user.name"));
+    connProp.setProperty("password", "");
+
+    HiveConnection connection = new HiveConnection("jdbc:hive2://localhost:10000/default",
connProp);
+    Statement stmt = connection.createStatement();
+    stmt.execute("create table testPostAnalysisHookContexts as select '3'");
+    Throwable error = PostExecHook.error;
+    if (error != null) {
+      throw error;
+    }
+    error = PreExecHook.error;
+    if (error != null) {
+      throw error;
+    }
+
+    Assert.assertEquals(HiveOperation.CREATETABLE_AS_SELECT, SemanticAnalysisHook.commandType);
+
+    error = SemanticAnalysisHook.preAnalyzeError;
+    if (error != null) {
+      throw error;
+    }
+    error = SemanticAnalysisHook.postAnalyzeError;
+    if (error != null) {
+      throw error;
+    }
+    stmt.close();
+    connection.close();
   }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/43d8647f/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveSemanticAnalyzerHookContextImpl.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveSemanticAnalyzerHookContextImpl.java
b/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveSemanticAnalyzerHookContextImpl.java
index 1cc38a8..e28dc47 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveSemanticAnalyzerHookContextImpl.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveSemanticAnalyzerHookContextImpl.java
@@ -58,6 +58,7 @@ public class HiveSemanticAnalyzerHookContextImpl implements HiveSemanticAnalyzer
   public void update(BaseSemanticAnalyzer sem) {
     this.inputs = sem.getInputs();
     this.outputs = sem.getOutputs();
+    this.commandType = sem.getQueryState().getHiveOperation();
   }
 
   @Override


Mime
View raw message