This is an automated email from the ASF dual-hosted git repository. vihangk1 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push: new 23ab7f2 HIVE-21484 : Metastore API getVersion() should return real version (Vihang Karajgaonkar reviewed by Naveen Gangam, Peter Vary) 23ab7f2 is described below commit 23ab7f2d5cc6fc7c7975235fcc7f77cde47e381f Author: Vihang Karajgaonkar <vihan...@apache.org> AuthorDate: Wed Mar 20 17:16:59 2019 -0700 HIVE-21484 : Metastore API getVersion() should return real version (Vihang Karajgaonkar reviewed by Naveen Gangam, Peter Vary) --- .../java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java | 5 +++++ .../java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java | 7 +++++++ .../main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java | 5 +++-- .../hadoop/hive/metastore/HiveMetaStoreClientPreCatalog.java | 5 +++++ .../java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java | 6 ++++++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java index fcd0d44..6357d06 100644 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java +++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java @@ -3839,4 +3839,9 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable { public void setHadoopJobid(String jobId, long cqId) throws MetaException, TException { client.set_hadoop_jobid(jobId, cqId); } + + @Override + public String getServerVersion() throws TException { + return client.getVersion(); + } } diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java index f67761e..8402ba5 100644 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java +++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java @@ -3948,4 +3948,11 @@ public interface IMetaStoreClient { * @throws TException */ void setHadoopJobid(String jobId, long cqId) throws MetaException, 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; } diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java index 510be01..854c85f 100644 --- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java +++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java @@ -5154,8 +5154,9 @@ public class HiveMetaStore extends ThriftHiveMetastore { @Override public String getVersion() throws TException { - endFunction(startFunction("getVersion"), true, null); - return "3.0"; + String version = MetastoreVersionInfo.getVersion(); + endFunction(startFunction("getVersion"), version != null, null); + return version; } @Override diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClientPreCatalog.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClientPreCatalog.java index 481abbc..e1450a5 100644 --- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClientPreCatalog.java +++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClientPreCatalog.java @@ -3644,4 +3644,9 @@ public class HiveMetaStoreClientPreCatalog implements IMetaStoreClient, AutoClos public void setHadoopJobid(String jobId, long cqId) throws MetaException, TException { client.set_hadoop_jobid(jobId, cqId); } + + @Override + public String getServerVersion() throws TException { + return client.getVersion(); + } } diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java index 77e0c98..0c4c84c 100644 --- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java +++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java @@ -57,6 +57,7 @@ import org.apache.hadoop.hive.metastore.conf.MetastoreConf; import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars; import org.apache.hadoop.hive.metastore.utils.FileUtils; import org.apache.hadoop.hive.metastore.utils.MetaStoreServerUtils; +import org.apache.hadoop.hive.metastore.utils.MetastoreVersionInfo; import org.apache.hadoop.hive.metastore.utils.SecurityUtils; import org.datanucleus.api.jdo.JDOPersistenceManager; import org.datanucleus.api.jdo.JDOPersistenceManagerFactory; @@ -3294,6 +3295,11 @@ public abstract class TestHiveMetaStore { assertEquals(numAPICallsPerThread * parallelCalls, size); } + @Test + public void testVersion() throws TException { + assertEquals(MetastoreVersionInfo.getVersion(), client.getServerVersion()); + } + /** * While altering partition(s), verify DO NOT calculate partition statistics if * <ol>