You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by th...@apache.org on 2015/09/25 22:09:43 UTC
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)
Repository: hive
Updated Branches:
refs/heads/branch-1 6fa9b5b71 -> bf2132218
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/bf213221
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/bf213221
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/bf213221
Branch: refs/heads/branch-1
Commit: bf21322189d44849c3787b99efe96278426e008c
Parents: 6fa9b5b
Author: Thejas Nair <th...@hortonworks.com>
Authored: Fri Sep 25 13:09:37 2015 -0700
Committer: Thejas Nair <th...@hortonworks.com>
Committed: Fri Sep 25 13:09:37 2015 -0700
----------------------------------------------------------------------
.../org/apache/hive/beeline/HiveSchemaTool.java | 25 +++++++++++++-------
1 file changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/bf213221/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 2477e5f..ed58fe0 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
@@ -177,9 +179,14 @@ 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);
}
}
@@ -433,8 +440,8 @@ public class HiveSchemaTool {
if ((!dbType.equalsIgnoreCase(HiveSchemaHelper.DB_DERBY) &&
!dbType.equalsIgnoreCase(HiveSchemaHelper.DB_MSSQL) &&
!dbType.equalsIgnoreCase(HiveSchemaHelper.DB_MYSQL) &&
- !dbType.equalsIgnoreCase(HiveSchemaHelper.DB_POSTGRACE) && !dbType
- .equalsIgnoreCase(HiveSchemaHelper.DB_ORACLE))) {
+ !dbType.equalsIgnoreCase(HiveSchemaHelper.DB_POSTGRACE) &&
+ !dbType.equalsIgnoreCase(HiveSchemaHelper.DB_ORACLE))) {
System.err.println("Unsupported dbType " + dbType);
printAndExit(cmdLineOptions);
}