Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C2507200D26 for ; Fri, 20 Oct 2017 18:55:43 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C0D66160BCB; Fri, 20 Oct 2017 16:55:43 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1383C1609ED for ; Fri, 20 Oct 2017 18:55:42 +0200 (CEST) Received: (qmail 79079 invoked by uid 500); 20 Oct 2017 16:55:42 -0000 Mailing-List: contact commits-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hive-dev@hive.apache.org Delivered-To: mailing list commits@hive.apache.org Received: (qmail 79068 invoked by uid 99); 20 Oct 2017 16:55:42 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Oct 2017 16:55:42 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 246DEDFA0E; Fri, 20 Oct 2017 16:55:39 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aihuaxu@apache.org To: commits@hive.apache.org Message-Id: <0e1ffe716cc84808b031fd75d1e8927f@git.apache.org> X-Mailer: ASF-Git Admin Mailer 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 +0000 (UTC) archived-at: Fri, 20 Oct 2017 16:55:43 -0000 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 Authored: Wed Oct 18 17:01:20 2017 -0700 Committer: Aihua Xu 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