use of org.apache.hadoop.hive.common.io.SessionStream in project hive by apache.
the class TestCliDriverMethods method testProcessSelectDatabase.
@Test
public void testProcessSelectDatabase() throws Exception {
CliSessionState sessinState = new CliSessionState(new HiveConf());
CliSessionState.start(sessinState);
ByteArrayOutputStream data = new ByteArrayOutputStream();
sessinState.err = new SessionStream(data);
sessinState.database = "database";
CliDriver driver = new CliDriver();
try {
driver.processSelectDatabase(sessinState);
fail("shuld be exit");
} catch (ExitException e) {
e.printStackTrace();
assertEquals(40000, e.getStatus());
}
assertTrue(data.toString().contains("FAILED: ParseException line 1:4 cannot recognize input near 'database'"));
}
use of org.apache.hadoop.hive.common.io.SessionStream in project hive by apache.
the class SQLOperation method setupSessionIO.
private void setupSessionIO(SessionState sessionState) {
try {
// hive server's session input stream is not used
sessionState.in = null;
sessionState.out = new SessionStream(System.out, true, StandardCharsets.UTF_8.name());
sessionState.info = new SessionStream(System.err, true, StandardCharsets.UTF_8.name());
sessionState.err = new SessionStream(System.err, true, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
log.error("Error creating PrintStream", e);
sessionState.out = null;
sessionState.info = null;
sessionState.err = null;
}
}
use of org.apache.hadoop.hive.common.io.SessionStream in project hive by apache.
the class TestSetProcessor method setupTest.
@Before
public void setupTest() throws Exception {
baos = new ByteArrayOutputStream();
state.out = new SessionStream(baos);
processor = new SetProcessor();
}
use of org.apache.hadoop.hive.common.io.SessionStream in project hive by apache.
the class TestCLIAuthzSessionContext method beforeTest.
@BeforeClass
public static void beforeTest() throws Exception {
HiveConf conf = new HiveConf();
conf.setVar(ConfVars.HIVE_AUTHORIZATION_MANAGER, MockedHiveAuthorizerFactory.class.getName());
conf.setVar(ConfVars.HIVE_AUTHENTICATOR_MANAGER, SessionStateUserAuthenticator.class.getName());
conf.setBoolVar(ConfVars.HIVE_AUTHORIZATION_ENABLED, true);
conf.setBoolVar(ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
// once SessionState for thread is set, CliDriver picks conf from it
CliSessionState ss = new CliSessionState(conf);
ss.err = new SessionStream(System.err);
ss.out = new SessionStream(System.out);
SessionState.start(ss);
TestCLIAuthzSessionContext.driver = new CliDriver();
}
use of org.apache.hadoop.hive.common.io.SessionStream in project hive by apache.
the class TestHiveHistory method testSimpleQuery.
/**
* Check history file output for this query.
*/
@Test
public void testSimpleQuery() {
new LineageInfo();
try {
// before any of the other core hive classes are loaded
try {
LogUtils.initHiveLog4j();
} catch (LogInitializationException e) {
}
HiveConf hconf = new HiveConf(SessionState.class);
hconf.setBoolVar(ConfVars.HIVE_SESSION_HISTORY_ENABLED, true);
CliSessionState ss = new CliSessionState(hconf);
ss.in = System.in;
try {
ss.out = new SessionStream(System.out, true, "UTF-8");
ss.err = new SessionStream(System.err, true, "UTF-8");
} catch (UnsupportedEncodingException e) {
System.exit(3);
}
SessionState.start(ss);
String cmd = "select a.key+1 from src a";
IDriver d = DriverFactory.newDriver(conf);
d.run(cmd);
HiveHistoryViewer hv = new HiveHistoryViewer(SessionState.get().getHiveHistory().getHistFileName());
Map<String, QueryInfo> jobInfoMap = hv.getJobInfoMap();
Map<String, TaskInfo> taskInfoMap = hv.getTaskInfoMap();
if (jobInfoMap.size() != 1) {
fail("jobInfo Map size not 1");
}
if (taskInfoMap.size() != 1) {
fail("jobInfo Map size not 1");
}
cmd = (String) jobInfoMap.keySet().toArray()[0];
QueryInfo ji = jobInfoMap.get(cmd);
if (!ji.hm.get(Keys.QUERY_NUM_TASKS.name()).equals("1")) {
fail("Wrong number of tasks");
}
} catch (Exception e) {
e.printStackTrace();
fail("Failed");
}
}
Aggregations