|
@@ -82,30 +82,27 @@ public class CliDriver {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
ret = qp.run(cmd);
|
|
|
Vector<Vector<String>> res = new Vector<Vector<String>>();
|
|
|
- while (qp.getResults(res))
|
|
|
- {
|
|
|
- SessionState ss = SessionState.get();
|
|
|
- OutputStream out = ss.out;
|
|
|
- try
|
|
|
- {
|
|
|
+ while (qp.getResults(res)) {
|
|
|
+ SessionState ss = SessionState.get();
|
|
|
+ PrintStream out = ss.out;
|
|
|
|
|
|
- for (Vector<String> row:res)
|
|
|
+ for (Vector<String> row:res)
|
|
|
+ {
|
|
|
+ boolean firstCol = true;
|
|
|
+ for (String col:row)
|
|
|
{
|
|
|
- for (String col:row)
|
|
|
- {
|
|
|
- out.write(col == null ? Utilities.nullStringOutput.getBytes() : col.getBytes());
|
|
|
+ if (!firstCol)
|
|
|
out.write(Utilities.tabCode);
|
|
|
- }
|
|
|
- out.write(Utilities.newLineCode);
|
|
|
- }
|
|
|
- res.clear();
|
|
|
-
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ out.print(col == null ? Utilities.nullStringOutput : col);
|
|
|
+ firstCol = false;
|
|
|
+ }
|
|
|
+ out.write(Utilities.newLineCode);
|
|
|
}
|
|
|
+ res.clear();
|
|
|
}
|
|
|
}
|
|
|
return ret;
|
|
@@ -151,16 +148,20 @@ public class CliDriver {
|
|
|
SessionState.initHiveLog4j();
|
|
|
|
|
|
CliSessionState ss = new CliSessionState (new HiveConf(SessionState.class));
|
|
|
+ ss.in = System.in;
|
|
|
+ try {
|
|
|
+ ss.out = new PrintStream(System.out, true, "UTF-8");
|
|
|
+ ss.err = new PrintStream(System.err, true, "UTF-8");
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ System.exit(3);
|
|
|
+ }
|
|
|
+
|
|
|
SessionState.start(ss);
|
|
|
|
|
|
if(! oproc.process_stage2(ss)) {
|
|
|
System.exit(2);
|
|
|
}
|
|
|
|
|
|
- ss.in = System.in;
|
|
|
- ss.out = System.out;
|
|
|
- ss.err = System.err;
|
|
|
-
|
|
|
sp = new SetProcessor();
|
|
|
qp = new Driver();
|
|
|
|