You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by vi...@apache.org on 2019/03/29 19:47:58 UTC

[hive] branch branch-2 updated: HIVE-21484 : Metastore API getVersion() should return real version (Vihang Karajgaonkar, reviewed by Naveen Gangam and Peter Vary)

This is an automated email from the ASF dual-hosted git repository.

vihangk1 pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new fd2f7c8  HIVE-21484 : Metastore API getVersion() should return real version (Vihang Karajgaonkar, reviewed by Naveen Gangam and Peter Vary)
fd2f7c8 is described below

commit fd2f7c85c84ad1f0a955325d886286d6eb515f16
Author: Vihang Karajgaonkar <vi...@apache.org>
AuthorDate: Fri Mar 29 12:47:05 2019 -0700

    HIVE-21484 : Metastore API getVersion() should return real version (Vihang Karajgaonkar, reviewed by Naveen Gangam and Peter Vary)
---
 .../java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java   | 6 ++++++
 .../src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java   | 6 ++++--
 .../java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java | 5 +++++
 .../java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java    | 7 +++++++
 4 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
index 8ba1b9a..7e919cc 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
@@ -35,6 +35,7 @@ import java.util.Set;
 
 import junit.framework.TestCase;
 
+import org.apache.hive.common.util.HiveVersionInfo;
 import org.datanucleus.api.jdo.JDOPersistenceManager;
 import org.datanucleus.api.jdo.JDOPersistenceManagerFactory;
 import org.slf4j.Logger;
@@ -3265,6 +3266,11 @@ public abstract class TestHiveMetaStore extends TestCase {
     silentDropDatabase(dbName);
   }
 
+  @Test
+  public void testVersion() throws TException {
+    assertEquals(HiveVersionInfo.getVersion(), client.getServerVersion());
+  }
+
   private void checkDbOwnerType(String dbName, String ownerName, PrincipalType ownerType)
       throws NoSuchObjectException, MetaException, TException {
     Database db = client.getDatabase(dbName);
diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
index 813b8aa..454b940 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
@@ -132,6 +132,7 @@ import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.util.ReflectionUtils;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.hive.common.util.HiveStringUtils;
+import org.apache.hive.common.util.HiveVersionInfo;
 import org.apache.hive.common.util.ShutdownHookManager;
 import org.apache.thrift.TException;
 import org.apache.thrift.TProcessor;
@@ -3988,8 +3989,9 @@ public class HiveMetaStore extends ThriftHiveMetastore {
 
     @Override
     public String getVersion() throws TException {
-      endFunction(startFunction("getVersion"), true, null);
-      return "3.0";
+      String version = HiveVersionInfo.getVersion();
+      endFunction(startFunction("getVersion"), version != null, null);
+      return version;
     }
 
     @Override
diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
index 83c2860..6dc198f 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
@@ -2567,4 +2567,9 @@ public class HiveMetaStoreClient implements IMetaStoreClient {
     CacheFileMetadataResult result = client.cache_file_metadata(req);
     return result.isIsSupported();
   }
+
+  @Override
+  public String getServerVersion() throws TException {
+    return client.getVersion();
+  }
 }
diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java b/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java
index a28c510..fb17187 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java
@@ -1704,4 +1704,11 @@ public interface IMetaStoreClient {
 
   void addForeignKey(List<SQLForeignKey> foreignKeyCols) throws
   MetaException, NoSuchObjectException, TException;
+
+  /**
+   * Gets the version string of the metastore server which this client is connected to
+   *
+   * @return String representation of the version number of Metastore server (eg: 3.1.0-SNAPSHOT)
+   */
+  String getServerVersion() throws TException;
 }