commit 0f6faf974c0a00269af881effc027c00a4b36949 Author: Thejas Nair Date: Thu Aug 20 13:57:17 2015 -0700 HIVE-11613 - initial change diff --git a/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java b/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java index 2477e5f..397bf0a 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 @@ private NestedScriptParser getDbCommandParser(String dbType) { */ 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 @@ -177,9 +179,15 @@ public void verifySchemaVersion() throws HiveMetaException { 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); } }