diff --git cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java index b4581fe..15e9c9b 100644 --- cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java +++ cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java @@ -115,8 +115,10 @@ public class CliDriver { // shell_cmd = "/bin/bash -c \'" + shell_cmd + "\'"; try { Process executor = Runtime.getRuntime().exec(shell_cmd); - StreamPrinter outPrinter = new StreamPrinter(executor.getInputStream(), null, ss.out); - StreamPrinter errPrinter = new StreamPrinter(executor.getErrorStream(), null, ss.err); + StreamPrinter outPrinter = new StreamPrinter(executor.getInputStream(), null, + SessionState.getConsole().getChildOutStream()); + StreamPrinter errPrinter = new StreamPrinter(executor.getErrorStream(), null, + SessionState.getConsole().getChildErrStream()); outPrinter.start(); errPrinter.start(); diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/MapRedTask.java ql/src/java/org/apache/hadoop/hive/ql/exec/MapRedTask.java index a53b6d5..8ff5768 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/MapRedTask.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/MapRedTask.java @@ -246,9 +246,9 @@ public class MapRedTask extends ExecDriver implements Serializable { executor = Runtime.getRuntime().exec(cmdLine, env, new File(workDir)); StreamPrinter outPrinter = new StreamPrinter(executor.getInputStream(), - null, System.out); + null, SessionState.getConsole().getChildOutStream()); StreamPrinter errPrinter = new StreamPrinter(executor.getErrorStream(), - null, System.err); + null, SessionState.getConsole().getChildErrStream()); outPrinter.start(); errPrinter.start(); diff --git ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java index 2f416a0..fdc0cb5 100644 --- ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java +++ ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java @@ -77,14 +77,25 @@ public class SessionState { * HiveHistory Object */ protected HiveHistory hiveHist; + /** * Streams to read/write from. */ - public PrintStream out; public InputStream in; + public PrintStream out; public PrintStream err; /** + * Standard output from any child process(es). + */ + public PrintStream childOut; + + /* + * Error output from any child process(es). + */ + public PrintStream childErr; + + /** * type of the command. */ private HiveOperation commandType; @@ -299,6 +310,16 @@ public class SessionState { return ((ss != null) && (ss.err != null)) ? ss.err : System.err; } + public PrintStream getChildOutStream() { + SessionState ss = SessionState.get(); + return ((ss != null) && (ss.childOut != null)) ? ss.childOut : ss.out; + } + + public PrintStream getChildErrStream() { + SessionState ss = SessionState.get(); + return ((ss != null) && (ss.childErr != null)) ? ss.childErr : ss.err; + } + public boolean getIsSilent() { SessionState ss = SessionState.get(); // use the session or the one supplied in constructor