diff --git a/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java b/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java index 2c088c9..56caa27 100644 --- a/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java +++ b/beeline/src/java/org/apache/hive/beeline/HiveSchemaTool.java @@ -593,29 +593,40 @@ public void doInit(String toVersion) throws HiveMetaException { } public void doValidate() throws HiveMetaException { - System.out.println("Starting metastore validation"); + System.out.println("Starting metastore validation\n"); Connection conn = getConnectionToMetastore(false); + boolean success = true; try { - if (validateSchemaVersions(conn)) + if (validateSchemaVersions(conn)) { System.out.println("[SUCCESS]\n"); - else + } else { + success = false; System.out.println("[FAIL]\n"); - if (validateSequences(conn)) + } + if (validateSequences(conn)) { System.out.println("[SUCCESS]\n"); - else + } else { + success = false; System.out.println("[FAIL]\n"); - if (validateSchemaTables(conn)) + } + if (validateSchemaTables(conn)) { System.out.println("[SUCCESS]\n"); - else + } else { + success = false; System.out.println("[FAIL]\n"); - if (validateLocations(conn, this.validationServers)) + } + if (validateLocations(conn, this.validationServers)) { System.out.println("[SUCCESS]\n"); - else + } else { + success = false; System.out.println("[FAIL]\n"); - if (validateColumnNullValues(conn)) + } + if (validateColumnNullValues(conn)) { System.out.println("[SUCCESS]\n"); - else + } else { + success = false; System.out.println("[FAIL]\n"); + } } finally { if (conn != null) { try { @@ -626,7 +637,13 @@ public void doValidate() throws HiveMetaException { } } - System.out.println("Done with metastore validation"); + System.out.print("Done with metastore validation: "); + if (!success) { + System.out.println("[FAIL]"); + System.exit(1); + } else { + System.out.println("[SUCCESS]"); + } } boolean validateSequences(Connection conn) throws HiveMetaException { @@ -719,14 +736,14 @@ boolean validateSchemaTables(Connection conn) throws HiveMetaException { version = getMetaStoreSchemaVersion(hmsConn); } catch (HiveMetaException he) { System.err.println("Failed to determine schema version from Hive Metastore DB," + he.getMessage()); - LOG.error("Failed to determine schema version from Hive Metastore DB," + he.getMessage()); + LOG.debug("Failed to determine schema version from Hive Metastore DB," + he.getMessage()); return false; } // re-open the hms connection hmsConn = getConnectionToMetastore(false); - LOG.info("Validating tables in the schema for version " + version); + LOG.debug("Validating tables in the schema for version " + version); try { metadata = conn.getMetaData(); String[] types = {"TABLE"}; @@ -760,7 +777,7 @@ boolean validateSchemaTables(Connection conn) throws HiveMetaException { subScripts.addAll(findCreateTable(schemaFile, schemaTables)); while (subScripts.size() > 0) { schemaFile = baseDir + "/" + dbType + "/" + subScripts.remove(0); - LOG.info("Parsing subscript " + schemaFile); + LOG.debug("Parsing subscript " + schemaFile); subScripts.addAll(findCreateTable(schemaFile, schemaTables)); } } catch (Exception e) { @@ -775,13 +792,12 @@ boolean validateSchemaTables(Connection conn) throws HiveMetaException { int schemaSize = schemaTables.size(); schemaTables.removeAll(dbTables); if (schemaTables.size() > 0) { - System.out.println("Found " + schemaSize + " tables in schema definition, " + - schemaTables.size() + " tables [ " + Arrays.toString(schemaTables.toArray()) + System.out.println("Table(s) [ " + Arrays.toString(schemaTables.toArray()) + " ] are missing from the metastore database schema."); System.out.println("Schema table validation failed!!!"); return false; } else { - System.out.println("Succeeded in schema table validation. " + schemaSize + " tables matched"); + System.out.println("Succeeded in schema table validation."); return true; } }