hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From the...@apache.org
Subject hive git commit: HIVE-11613 : schematool should return non zero exit status for info command, if state is inconsistent (Thejas Nair, reviewed by Prasad Mujumdar)
Date Fri, 25 Sep 2015 20:10:54 GMT
Repository: hive
Updated Branches:
  refs/heads/master 6c2d71cb4 -> a4eb3c5d4


HIVE-11613 : schematool should return non zero exit status for info command, if state is inconsistent
(Thejas Nair, reviewed by Prasad Mujumdar)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/a4eb3c5d
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/a4eb3c5d
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/a4eb3c5d

Branch: refs/heads/master
Commit: a4eb3c5d4ce06e7c914775870618f46f4898b8ab
Parents: 6c2d71c
Author: Thejas Nair <thejas@hortonworks.com>
Authored: Fri Sep 25 13:10:49 2015 -0700
Committer: Thejas Nair <thejas@hortonworks.com>
Committed: Fri Sep 25 13:10:49 2015 -0700

----------------------------------------------------------------------
 .../org/apache/hive/beeline/HiveSchemaTool.java | 22 +++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/a4eb3c5d/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java
----------------------------------------------------------------------
diff --git a/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java b/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java
index d5d635a..9e72a3a 100644
--- a/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java
+++ b/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java
@@ -125,10 +125,12 @@ public class HiveSchemaTool {
    */
   public void showInfo() throws HiveMetaException {
     Connection metastoreConn = getConnectionToMetastore(true);
-    System.out.println("Hive distribution version:\t " +
-        MetaStoreSchemaInfo.getHiveSchemaVersion());
-    System.out.println("Metastore schema version:\t " +
-        getMetaStoreSchemaVersion(metastoreConn));
+    String hiveVersion = MetaStoreSchemaInfo.getHiveSchemaVersion();
+    String dbVersion = getMetaStoreSchemaVersion(metastoreConn);
+    System.out.println("Hive distribution version:\t " + hiveVersion);
+    System.out.println("Metastore schema version:\t " + dbVersion);
+    assertSameVersion(hiveVersion, dbVersion);
+
   }
 
   // read schema version from metastore
@@ -183,9 +185,15 @@ public class HiveSchemaTool {
     String newSchemaVersion = getMetaStoreSchemaVersion(
         getConnectionToMetastore(false));
     // verify that the new version is added to schema
-    if (!MetaStoreSchemaInfo.getHiveSchemaVersion().equalsIgnoreCase(newSchemaVersion)) {
-      throw new HiveMetaException("Expected schema version " + MetaStoreSchemaInfo.getHiveSchemaVersion()
+
-        ", found version " + newSchemaVersion);
+    assertSameVersion(MetaStoreSchemaInfo.getHiveSchemaVersion(), newSchemaVersion);
+
+  }
+
+  private void assertSameVersion(String hiveSchemaVersion, String dbSchemaVersion)
+      throws HiveMetaException {
+    if (!hiveSchemaVersion.equalsIgnoreCase(dbSchemaVersion)) {
+      throw new HiveMetaException("Expected schema version " + hiveSchemaVersion
+          + ", found version " + dbSchemaVersion);
     }
   }
 


Mime
View raw message