You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by th...@apache.org on 2013/09/06 02:39:03 UTC
svn commit: r1520465 - in /hive/trunk:
beeline/src/test/org/apache/hive/beeline/src/test/TestBeeLineWithArgs.java
jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
Author: thejas
Date: Fri Sep 6 00:39:03 2013
New Revision: 1520465
URL: http://svn.apache.org/r1520465
Log:
HIVE-5131: JDBC client's hive variables are not passed to HS2 (Xuefu Zhang via Thejas Nair)
Modified:
hive/trunk/beeline/src/test/org/apache/hive/beeline/src/test/TestBeeLineWithArgs.java
hive/trunk/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
Modified: hive/trunk/beeline/src/test/org/apache/hive/beeline/src/test/TestBeeLineWithArgs.java
URL: http://svn.apache.org/viewvc/hive/trunk/beeline/src/test/org/apache/hive/beeline/src/test/TestBeeLineWithArgs.java?rev=1520465&r1=1520464&r2=1520465&view=diff
==============================================================================
--- hive/trunk/beeline/src/test/org/apache/hive/beeline/src/test/TestBeeLineWithArgs.java (original)
+++ hive/trunk/beeline/src/test/org/apache/hive/beeline/src/test/TestBeeLineWithArgs.java Fri Sep 6 00:39:03 2013
@@ -40,7 +40,9 @@ import org.junit.Test;
public class TestBeeLineWithArgs {
// Default location of HiveServer2
- final static String JDBC_URL = BeeLine.BEELINE_DEFAULT_JDBC_URL + "localhost:10000";
+ final static String BASE_JDBC_URL = BeeLine.BEELINE_DEFAULT_JDBC_URL + "localhost:10000";
+ //set JDBC_URL to something else in test case, if it needs to be customized
+ String JDBC_URL = BASE_JDBC_URL;
private static HiveServer2 hiveServer2;
@@ -100,7 +102,7 @@ public class TestBeeLineWithArgs {
* in the output (stdout or stderr), fail if not found
* Print PASSED or FAILED
* @paramm testName Name of test to print
- * @param expecttedPattern Text to look for in command output
+ * @param expectedPattern Text to look for in command output/error
* @param shouldMatch true if the pattern should be found, false if it should not
* @throws Exception on command execution error
*/
@@ -239,4 +241,13 @@ public class TestBeeLineWithArgs {
System.out.println(">>> PASSED " + "testNPE" );
}
+ @Test
+ public void testHiveVarSubstitution() throws Throwable {
+ JDBC_URL = BASE_JDBC_URL + "#D_TBL=dummy_t";
+ final String TEST_NAME = "testHiveVarSubstitution";
+ final String SCRIPT_TEXT = "create table ${D_TBL} (d int);\nshow tables;\n";
+ final String EXPECTED_PATTERN = "dummy_t";
+ testScriptFile(TEST_NAME, SCRIPT_TEXT, EXPECTED_PATTERN, true);
+ }
+
}
Modified: hive/trunk/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
URL: http://svn.apache.org/viewvc/hive/trunk/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java?rev=1520465&r1=1520464&r2=1520465&view=diff
==============================================================================
--- hive/trunk/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java (original)
+++ hive/trunk/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java Fri Sep 6 00:39:03 2013
@@ -34,12 +34,12 @@ import java.sql.Savepoint;
import java.sql.Statement;
import java.sql.Struct;
import java.util.HashMap;
-import java.util.concurrent.Executor;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
+import java.util.concurrent.Executor;
import javax.security.sasl.Sasl;
import javax.security.sasl.SaslException;
@@ -124,6 +124,12 @@ public class HiveConnection implements j
stmt.execute("set " + hiveConf.getKey() + "=" + hiveConf.getValue());
stmt.close();
}
+
+ // For remote JDBC client, try to set the hive var using 'set hivevar:key=value'
+ for (Entry<String, String> hiveVar : connParams.getHiveVars().entrySet()) {
+ stmt.execute("set hivevar:" + hiveVar.getKey() + "=" + hiveVar.getValue());
+ stmt.close();
+ }
}
}