use of org.apache.hadoop.hive.metastore.tools.schematool.HiveSchemaHelper.NestedScriptParser in project hive by apache.
the class MetastoreSchemaTool method init.
@VisibleForTesting
public void init(String metastoreHome, String[] args, OptionGroup additionalOptions, Configuration conf) throws HiveMetaException {
try {
cmdLine = new SchemaToolCommandLine(args, additionalOptions);
} catch (ParseException e) {
System.err.println("Failed to parse command line. ");
throw new HiveMetaException(e);
}
if (metastoreHome == null || metastoreHome.isEmpty()) {
throw new HiveMetaException("No Metastore home directory provided");
}
this.conf = conf;
this.dbType = cmdLine.getDbType();
this.metaDbType = cmdLine.getMetaDbType();
NestedScriptParser parser = getDbCommandParser(dbType, metaDbType);
this.needsQuotedIdentifier = parser.needsQuotedIdentifier();
this.quoteCharacter = parser.getQuoteCharacter();
this.metaStoreSchemaInfo = MetaStoreSchemaInfoFactory.get(conf, metastoreHome, dbType);
// It is overridden by command line options if passed (-url and -driver)
if (dbType.equalsIgnoreCase(HiveSchemaHelper.DB_HIVE)) {
this.url = HiveSchemaHelper.EMBEDDED_HS2_URL;
this.driver = HiveSchemaHelper.HIVE_JDBC_DRIVER;
}
if (cmdLine.hasOption("userName")) {
setUserName(cmdLine.getOptionValue("userName"));
} else {
setUserName(getConf().get(MetastoreConf.ConfVars.CONNECTION_USER_NAME.getVarname()));
}
if (cmdLine.hasOption("passWord")) {
setPassWord(cmdLine.getOptionValue("passWord"));
} else {
try {
setPassWord(MetastoreConf.getPassword(getConf(), ConfVars.PWD));
} catch (IOException err) {
throw new HiveMetaException("Error getting metastore password", err);
}
}
if (cmdLine.hasOption("url")) {
setUrl(cmdLine.getOptionValue("url"));
}
if (cmdLine.hasOption("driver")) {
setDriver(cmdLine.getOptionValue("driver"));
}
if (cmdLine.hasOption("dryRun")) {
setDryRun(true);
}
if (cmdLine.hasOption("verbose")) {
setVerbose(true);
}
if (cmdLine.hasOption("dbOpts")) {
setDbOpts(cmdLine.getOptionValue("dbOpts"));
}
if (cmdLine.hasOption("validate") && cmdLine.hasOption("servers")) {
setValidationServers(cmdLine.getOptionValue("servers"));
}
if (cmdLine.hasOption("hiveUser")) {
setHiveUser(cmdLine.getOptionValue("hiveUser"));
}
if (cmdLine.hasOption("hivePassword")) {
setHivePasswd(cmdLine.getOptionValue("hivePassword"));
}
if (cmdLine.hasOption("hiveDb")) {
setHiveDb(cmdLine.getOptionValue("hiveDb"));
}
}
Aggregations