diff --git a/beeline/src/java/org/apache/hive/beeline/BeeLine.java b/beeline/src/java/org/apache/hive/beeline/BeeLine.java index d8e44de..e96d933 100644 --- a/beeline/src/java/org/apache/hive/beeline/BeeLine.java +++ b/beeline/src/java/org/apache/hive/beeline/BeeLine.java @@ -694,7 +694,6 @@ int initArgsFromCliVars(String[] args) { if (!commands.isEmpty()) { embeddedConnect(); connectDBInEmbededMode(); - updateOptsForCli(); for (Iterator i = commands.iterator(); i.hasNext(); ) { String command = i.next().toString(); debug(loc("executing-command", command)); @@ -811,7 +810,7 @@ private String obtainPasswordFromFile(String passwordFilePath) { } } - private void updateOptsForCli() { + public void updateOptsForCli() { getOpts().updateBeeLineOptsFromConf(); getOpts().setShowHeader(false); getOpts().setOutputFormat("dsv"); @@ -844,9 +843,6 @@ public int begin(String[] args, InputStream inputStream) throws IOException { return code; } defaultConnect(false); - updateOptsForCli(); - - processInitFiles(opts.getInitFiles()); } if (getOpts().getScriptFile() != null) { @@ -934,24 +930,6 @@ private int executeFile(String fileName) { } } - /** - * Only initial files specified by i option will be executed. The hiverc file will be processed by session manager. - * - * @param files - * @throws IOException - */ - public void processInitFiles(String[] files) throws IOException { - if (files == null || files.length == 0) { - return; - } - for (String initFile : files) { - int rc = executeFile(initFile); - if (rc != 0) { - System.exit(rc); - } - } - } - private int execute(ConsoleReader reader, boolean exitOnError) { String line; while (!exit) { diff --git a/beeline/src/java/org/apache/hive/beeline/Commands.java b/beeline/src/java/org/apache/hive/beeline/Commands.java index d16b4ec..44dd18b 100644 --- a/beeline/src/java/org/apache/hive/beeline/Commands.java +++ b/beeline/src/java/org/apache/hive/beeline/Commands.java @@ -1389,6 +1389,10 @@ public boolean connect(Properties props) throws IOException { beeLine.getDatabaseConnections().setConnection( new DatabaseConnection(beeLine, driver, url, props)); beeLine.getDatabaseConnection().getConnection(); + + if (!beeLine.isBeeLine()) { + beeLine.updateOptsForCli(); + } beeLine.runInit(); beeLine.setCompletions();