commit f681dcdc052d5bf956ed11b13e503bb604d1f3e2 Author: Vihang Karajgaonkar Date: Wed Mar 20 17:16:59 2019 -0700 HIVE-21484 : Metastore API getVersion() should return real version 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 fcd0d44acd9caa2468422e1142ad35aa47c4121e..6357d06b5a321b2020c8202cf8ec224fc725e463 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 void markFailed(CompactionInfoStruct cr) throws MetaException, TException 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 f67761eb6ef363596db9ccc16e04f1457539f18b..8402ba57ddbec3cdb2b9a0332ba6cd0989feeb7c 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 @@ void createOrDropTriggerToPoolMapping(String resourcePlanName, String triggerNam * @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 510be01c3490eeb6dc051ecefb15de10229ed358..854c85f96966b81ea00558c764e6d1e8dc55125d 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 @@ private void alter_partitions_with_environment_context(String catName, String db @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 481abbccafb99a3195307b6df532acc539d86dac..e1450a5d541332b05fef431bc5483d6ea339baaa 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 void markFailed(CompactionInfoStruct cr) throws MetaException, TException 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 77e0c98265e7b561f2eb39536e3251dd92e9cab0..0c4c84ce0b3135b4ffe5059061720ed1424dcda7 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.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 void testGetUUIDInParallel() throws Exception { 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 *