You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2013/04/29 20:28:15 UTC

svn commit: r1477255 - in /hive/branches/branch-0.11: common/ jdbc/src/java/org/apache/hive/jdbc/ jdbc/src/test/org/apache/hive/jdbc/ service/src/java/org/apache/hive/service/cli/session/

Author: hashutosh
Date: Mon Apr 29 18:28:15 2013
New Revision: 1477255

URL: http://svn.apache.org/r1477255
Log:
HIVE-4373 : Hive Version returned by HiveDatabaseMetaData.getDatabaseProductVersion is incorrect (Thejas Nair via Ashutosh Chauhan)

Modified:
    hive/branches/branch-0.11/common/build.xml
    hive/branches/branch-0.11/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java
    hive/branches/branch-0.11/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java
    hive/branches/branch-0.11/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java

Modified: hive/branches/branch-0.11/common/build.xml
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.11/common/build.xml?rev=1477255&r1=1477254&r2=1477255&view=diff
==============================================================================
--- hive/branches/branch-0.11/common/build.xml (original)
+++ hive/branches/branch-0.11/common/build.xml Mon Apr 29 18:28:15 2013
@@ -25,6 +25,7 @@ to call at top-level: ant deploy-contrib
 <project name="common" default="jar">
 
   <property name="src.dir"  location="${basedir}/src/java"/>
+  <property name="src.gen.dir"  location="${basedir}/src/gen"/>
   <import file="../build-common.xml"/>
 
   <target name="compile" depends="init, setup, ivy-retrieve">
@@ -36,7 +37,7 @@ to call at top-level: ant deploy-contrib
     </exec>
     <javac
      encoding="${build.encoding}"
-     srcdir="${src.dir}"
+     srcdir="${src.dir}:${src.gen.dir}"
      includes="**/*.java"
      destdir="${build.classes}"
      debug="${javac.debug}"

Modified: hive/branches/branch-0.11/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.11/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java?rev=1477255&r1=1477254&r2=1477255&view=diff
==============================================================================
--- hive/branches/branch-0.11/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java (original)
+++ hive/branches/branch-0.11/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java Mon Apr 29 18:28:15 2013
@@ -28,12 +28,16 @@ import java.util.Comparator;
 import java.util.jar.Attributes;
 
 import org.apache.hadoop.hive.metastore.TableType;
+import org.apache.hive.service.cli.GetInfoType;
+import org.apache.hive.service.cli.thrift.TCLIService;
 import org.apache.hive.service.cli.thrift.TGetCatalogsReq;
 import org.apache.hive.service.cli.thrift.TGetCatalogsResp;
 import org.apache.hive.service.cli.thrift.TGetColumnsReq;
 import org.apache.hive.service.cli.thrift.TGetColumnsResp;
 import org.apache.hive.service.cli.thrift.TGetFunctionsReq;
 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.TGetSchemasReq;
 import org.apache.hive.service.cli.thrift.TGetSchemasResp;
 import org.apache.hive.service.cli.thrift.TGetTableTypesReq;
@@ -42,7 +46,6 @@ import org.apache.hive.service.cli.thrif
 import org.apache.hive.service.cli.thrift.TGetTablesResp;
 import org.apache.hive.service.cli.thrift.TGetTypeInfoReq;
 import org.apache.hive.service.cli.thrift.TGetTypeInfoResp;
-import org.apache.hive.service.cli.thrift.TCLIService;
 import org.apache.hive.service.cli.thrift.TSessionHandle;
 import org.apache.thrift.TException;
 
@@ -249,8 +252,17 @@ public class HiveDatabaseMetaData implem
   }
 
   public String getDatabaseProductVersion() throws SQLException {
-    // TODO: Fetch this from the server side
-    return "0.10.0";
+
+    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());
+
+    return resp.getInfoValue().getStringValue();
   }
 
   public int getDefaultTransactionIsolation() throws SQLException {

Modified: hive/branches/branch-0.11/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.11/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java?rev=1477255&r1=1477254&r2=1477255&view=diff
==============================================================================
--- hive/branches/branch-0.11/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java (original)
+++ hive/branches/branch-0.11/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java Mon Apr 29 18:28:15 2013
@@ -35,11 +35,13 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import java.util.regex.Pattern;
 
 import junit.framework.TestCase;
 
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hive.common.util.HiveVersionInfo;
 
 /**
  * TestJdbcDriver2
@@ -833,7 +835,11 @@ public class TestJdbcDriver2 extends Tes
     DatabaseMetaData meta = con.getMetaData();
 
     assertEquals("Hive", meta.getDatabaseProductName());
-    assertEquals("0.10.0", meta.getDatabaseProductVersion());
+    assertEquals(HiveVersionInfo.getVersion(), meta.getDatabaseProductVersion());
+    assertEquals(System.getProperty("hive.version"), meta.getDatabaseProductVersion());
+    assertTrue("verifying hive version pattern. got " + meta.getDatabaseProductVersion(),
+        Pattern.matches("\\d+\\.\\d+\\.\\d+.*", meta.getDatabaseProductVersion()) );
+
     assertEquals(DatabaseMetaData.sqlStateSQL99, meta.getSQLStateType());
     assertFalse(meta.supportsCatalogsInTableDefinitions());
     assertFalse(meta.supportsSchemasInTableDefinitions());

Modified: hive/branches/branch-0.11/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.11/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java?rev=1477255&r1=1477254&r2=1477255&view=diff
==============================================================================
--- hive/branches/branch-0.11/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java (original)
+++ hive/branches/branch-0.11/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java Mon Apr 29 18:28:15 2013
@@ -29,6 +29,7 @@ import org.apache.hadoop.hive.metastore.
 import org.apache.hadoop.hive.metastore.IMetaStoreClient;
 import org.apache.hadoop.hive.metastore.api.MetaException;
 import org.apache.hadoop.hive.ql.session.SessionState;
+import org.apache.hive.common.util.HiveVersionInfo;
 import org.apache.hive.service.cli.FetchOrientation;
 import org.apache.hive.service.cli.GetInfoType;
 import org.apache.hive.service.cli.GetInfoValue;
@@ -144,7 +145,7 @@ public class HiveSessionImpl implements 
       case CLI_DBMS_NAME:
         return new GetInfoValue("Apache Hive");
       case CLI_DBMS_VER:
-        return new GetInfoValue("0.10.0");
+        return new GetInfoValue(HiveVersionInfo.getVersion());
       case CLI_MAX_COLUMN_NAME_LEN:
         return new GetInfoValue(128);
       case CLI_MAX_SCHEMA_NAME_LEN: