FAQ
Author: kevinwilfong
Date: Thu Sep 13 09:11:23 2012
New Revision: 1384247

URL: http://svn.apache.org/viewvc?rev=1384247&view=rev
Log:
HIVE-3391. Keep the original query in HiveDriverRunHookContextImpl. (Dawid Dabrowski via kevinwilfong)

Added:
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/hooks/DriverTestHook.java
hive/trunk/ql/src/test/queries/clientpositive/driverhook.q
hive/trunk/ql/src/test/results/clientpositive/driverhook.q.out
Modified:
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/HiveDriverRunHookContext.java
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/HiveDriverRunHookContextImpl.java

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/Driver.java?rev=1384247&r1=1384246&r2=1384247&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/Driver.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/Driver.java Thu Sep 13 09:11:23 2012
@@ -879,7 +879,7 @@ public class Driver implements CommandPr
errorMessage = null;
SQLState = null;

- HiveDriverRunHookContext hookContext = new HiveDriverRunHookContextImpl(conf);
+ HiveDriverRunHookContext hookContext = new HiveDriverRunHookContextImpl(conf, command);
// Get all the driver run hooks and pre-execute them.
List<HiveDriverRunHook> driverRunHooks;
try {

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/HiveDriverRunHookContext.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/HiveDriverRunHookContext.java?rev=1384247&r1=1384246&r2=1384247&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/HiveDriverRunHookContext.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/HiveDriverRunHookContext.java Thu Sep 13 09:11:23 2012
@@ -25,5 +25,6 @@ import org.apache.hadoop.conf.Configurab
* HiveDriverRunHook.
*/
public interface HiveDriverRunHookContext extends Configurable{
-
+ public String getCommand();
+ public void setCommand(String command);
}

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/HiveDriverRunHookContextImpl.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/HiveDriverRunHookContextImpl.java?rev=1384247&r1=1384246&r2=1384247&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/HiveDriverRunHookContextImpl.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/HiveDriverRunHookContextImpl.java Thu Sep 13 09:11:23 2012
@@ -22,10 +22,12 @@ import org.apache.hadoop.conf.Configurat

public class HiveDriverRunHookContextImpl implements HiveDriverRunHookContext {

- Configuration conf;
+ private Configuration conf;
+ private String command;

- public HiveDriverRunHookContextImpl(Configuration conf) {
+ public HiveDriverRunHookContextImpl(Configuration conf, String command) {
this.conf = conf;
+ this.command = command;
}

@Override
@@ -37,4 +39,14 @@ public class HiveDriverRunHookContextImp
public void setConf(Configuration conf) {
this.conf = conf;
}
+
+ @Override
+ public String getCommand() {
+ return command;
+ }
+
+ @Override
+ public void setCommand(String command) {
+ this.command = command;
+ }
}

Added: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/hooks/DriverTestHook.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/hooks/DriverTestHook.java?rev=1384247&view=auto
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/hooks/DriverTestHook.java (added)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/hooks/DriverTestHook.java Thu Sep 13 09:11:23 2012
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.hooks;
+
+import java.io.PrintStream;
+
+import org.apache.hadoop.hive.ql.HiveDriverRunHook;
+import org.apache.hadoop.hive.ql.HiveDriverRunHookContext;
+import org.apache.hadoop.hive.ql.session.SessionState;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.conf.HiveConf;
+
+public class DriverTestHook implements HiveDriverRunHook {
+
+ @Override
+ public void preDriverRun(HiveDriverRunHookContext hookContext) throws Exception {
+ SessionState sess = new SessionState((HiveConf)hookContext.getConf());
+ PrintStream stream = sess.getConsole().getOutStream();
+ stream.println(hookContext.getCommand());
+ }
+
+ @Override
+ public void postDriverRun(HiveDriverRunHookContext hookContext) throws Exception {
+ // do nothing
+ }
+}

Added: hive/trunk/ql/src/test/queries/clientpositive/driverhook.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/driverhook.q?rev=1384247&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/driverhook.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/driverhook.q Thu Sep 13 09:11:23 2012
@@ -0,0 +1,6 @@
+SET hive.exec.driver.run.hooks=org.apache.hadoop.hive.ql.hooks.DriverTestHook;
+
+-- This query should appear in the Hive CLI output.
+-- We test DriverTestHook, which does exactly that.
+-- This should not break.
+SELECT * FROM src LIMIT 1;

Added: hive/trunk/ql/src/test/results/clientpositive/driverhook.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/driverhook.q.out?rev=1384247&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/driverhook.q.out (added)
+++ hive/trunk/ql/src/test/results/clientpositive/driverhook.q.out Thu Sep 13 09:11:23 2012
@@ -0,0 +1,21 @@
+
+
+-- This query should appear in the Hive CLI output.
+-- We test DriverTestHook, which does exactly that.
+-- This should not break.
+SELECT * FROM src LIMIT 1
+PREHOOK: query: -- This query should appear in the Hive CLI output.
+-- We test DriverTestHook, which does exactly that.
+-- This should not break.
+SELECT * FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: -- This query should appear in the Hive CLI output.
+-- We test DriverTestHook, which does exactly that.
+-- This should not break.
+SELECT * FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+238 val_238

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categorieshive, hadoop
postedSep 13, '12 at 9:12a
activeSep 13, '12 at 9:12a
posts1
users1
websitehive.apache.org

1 user in discussion

Kevinwilfong: 1 post

People

Translate

site design / logo © 2021 Grokbase