// Generate the beeline args per hive conf and execute the given script public void runBeeLine(String sqlScriptFile) throws IOException { List<String> argList = new ArrayList<String>(); argList.add("-u"); argList.add(HiveSchemaHelper.getValidConfVar(ConfVars.METASTORECONNECTURLKEY, hiveConf)); argList.add("-d"); argList.add(HiveSchemaHelper.getValidConfVar(ConfVars.METASTORE_CONNECTION_DRIVER, hiveConf)); argList.add("-n"); argList.add(userName); argList.add("-p"); argList.add(passWord); argList.add("-f"); argList.add(sqlScriptFile); // run the script using Beeline BeeLine beeLine = new BeeLine(); if (!verbose) { beeLine.setOutputStream(new PrintStream(new NullOutputStream())); beeLine.getOpts().setSilent(true); } beeLine.getOpts().setAllowMultiLineCommand(false); beeLine.getOpts().setIsolation("TRANSACTION_READ_COMMITTED"); int status = beeLine.begin(argList.toArray(new String[0]), null); if (status != 0) { throw new IOException("Schema script failed, errorcode " + status); } }
private NestedScriptParser getDbCommandParser(String dbType) { return HiveSchemaHelper.getDbCommandParser(dbType, dbOpts, userName, passWord, hiveConf); }
private Connection getConnectionToMetastore(boolean printInfo) throws HiveMetaException { return HiveSchemaHelper.getConnectionToMetastore(userName, passWord, printInfo, hiveConf); }