diff --git cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java index 2b52826..f97bba7 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 2b0dba8..417586b 100644 --- ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java +++ ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java @@ -72,14 +72,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; @@ -286,6 +297,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 : getOutStream(); + } + + public PrintStream getChildErrStream() { + SessionState ss = SessionState.get(); + return ((ss != null) && (ss.childErr != null)) ? ss.childErr : getErrStream(); + } + public boolean getIsSilent() { SessionState ss = SessionState.get(); // use the session or the one supplied in constructor