@Override
  void execute() throws HiveMetaException {
    HiveSchemaHelper.MetaStoreConnectionInfo connectionInfo = schemaTool.getConnectionInfo(true);
    String dbVersion = null;
    try {
      dbVersion = schemaTool.getMetaStoreSchemaInfo().getMetaStoreSchemaVersion(connectionInfo);
    } catch (HiveMetaException e) {
      LOG.info("Exception getting db version:" + e.getMessage());
      LOG.info("Try to initialize db schema");
    }
    SchemaToolTask task;
    if (dbVersion == null) {
      task = new SchemaToolTaskInit();
    } else {
      task = new SchemaToolTaskUpgrade();
    }
    task.setHiveSchemaTool(schemaTool);
    task.setCommandLineArguments(cl);
    task.execute();
  }
Perform metastore schema init or upgrade based on schema version
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/tools/schematool/SchemaToolTaskInitOrUpgrade.java