You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by se...@apache.org on 2015/09/28 21:10:35 UTC

[33/43] 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)

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/llap
Commit: a4eb3c5d4ce06e7c914775870618f46f4898b8ab
Parents: 6c2d71c
Author: Thejas Nair <th...@hortonworks.com>
Authored: Fri Sep 25 13:10:49 2015 -0700
Committer: Thejas Nair <th...@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);
     }
   }