hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pras...@apache.org
Subject svn commit: r1550788 - in /hive/trunk: itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java
Date Fri, 13 Dec 2013 18:21:58 GMT
Author: prasadm
Date: Fri Dec 13 18:21:58 2013
New Revision: 1550788

URL: http://svn.apache.org/r1550788
Log:
HIVE-5993: JDBC Driver should not hard-code the database name (Szehon Ho via Prasad Mujumdar)

Modified:
    hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
    hive/trunk/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java

Modified: hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
URL: http://svn.apache.org/viewvc/hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java?rev=1550788&r1=1550787&r2=1550788&view=diff
==============================================================================
--- hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java (original)
+++ hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java Fri
Dec 13 18:21:58 2013
@@ -1304,7 +1304,7 @@ public class TestJdbcDriver2 {
   public void testDatabaseMetaData() throws SQLException {
     DatabaseMetaData meta = con.getMetaData();
 
-    assertEquals("Hive", meta.getDatabaseProductName());
+    assertEquals("Apache Hive", meta.getDatabaseProductName());
     assertEquals(HiveVersionInfo.getVersion(), meta.getDatabaseProductVersion());
     assertEquals(System.getProperty("hive.version"), meta.getDatabaseProductVersion());
     assertTrue("verifying hive version pattern. got " + meta.getDatabaseProductVersion(),

Modified: hive/trunk/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/hive/trunk/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java?rev=1550788&r1=1550787&r2=1550788&view=diff
==============================================================================
--- hive/trunk/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java (original)
+++ hive/trunk/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java Fri Dec 13 18:21:58
2013
@@ -38,6 +38,7 @@ import org.apache.hive.service.cli.thrif
 import org.apache.hive.service.cli.thrift.TGetFunctionsResp;
 import org.apache.hive.service.cli.thrift.TGetInfoReq;
 import org.apache.hive.service.cli.thrift.TGetInfoResp;
+import org.apache.hive.service.cli.thrift.TGetInfoType;
 import org.apache.hive.service.cli.thrift.TGetSchemasReq;
 import org.apache.hive.service.cli.thrift.TGetSchemasResp;
 import org.apache.hive.service.cli.thrift.TGetTableTypesReq;
@@ -265,7 +266,8 @@ public class HiveDatabaseMetaData implem
   }
 
   public String getDatabaseProductName() throws SQLException {
-    return "Hive";
+    TGetInfoResp resp = getServerInfo(GetInfoType.CLI_DBMS_NAME.toTGetInfoType());
+    return resp.getInfoValue().getStringValue();
   }
 
   public String getDatabaseProductVersion() throws SQLException {
@@ -273,15 +275,7 @@ public class HiveDatabaseMetaData implem
       return dbVersion;
     }
 
-    TGetInfoReq req = new TGetInfoReq(sessHandle, GetInfoType.CLI_DBMS_VER.toTGetInfoType());
-    TGetInfoResp resp;
-    try {
-      resp = client.GetInfo(req);
-    } catch (TException e) {
-      throw new SQLException(e.getMessage(), "08S01", e);
-    }
-    Utils.verifySuccess(resp.getStatus());
-
+    TGetInfoResp resp = getServerInfo(GetInfoType.CLI_DBMS_VER.toTGetInfoType());
     this.dbVersion = resp.getInfoValue().getStringValue();
     return dbVersion;
   }
@@ -1137,4 +1131,16 @@ public class HiveDatabaseMetaData implem
     System.out.println("DriverName: " + meta.getDriverName());
     System.out.println("DriverVersion: " + meta.getDriverVersion());
   }
+
+  private TGetInfoResp getServerInfo(TGetInfoType type) throws SQLException {
+    TGetInfoReq req = new TGetInfoReq(sessHandle, type);
+    TGetInfoResp resp;
+    try {
+      resp = client.GetInfo(req);
+    } catch (TException e) {
+      throw new SQLException(e.getMessage(), "08S01", e);
+    }
+    Utils.verifySuccess(resp.getStatus());
+    return resp;
+  }
 }



Mime
View raw message