use of org.apache.hadoop.hive.ql.IDriver in project hive by apache.
the class TestSemanticAnalyzerHookLoading method testHookLoading.
public void testHookLoading() throws Exception {
HiveConf conf = new HiveConf(this.getClass());
conf.set(ConfVars.SEMANTIC_ANALYZER_HOOK.varname, DummySemanticAnalyzerHook.class.getName());
conf.set(ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, "false");
SessionState.start(conf);
IDriver driver = DriverFactory.newDriver(conf);
driver.run("drop table testDL");
CommandProcessorResponse resp = driver.run("create table testDL (a int) as select * from tbl2");
assertEquals(40000, resp.getResponseCode());
resp = driver.run("create table testDL (a int)");
assertEquals(0, resp.getResponseCode());
assertNull(resp.getErrorMessage());
Map<String, String> params = Hive.get(conf).getTable(Warehouse.DEFAULT_DATABASE_NAME, "testDL").getParameters();
assertEquals(DummyCreateTableHook.class.getName(), params.get("createdBy"));
assertEquals("Open Source rocks!!", params.get("Message"));
driver.run("drop table testDL");
}
use of org.apache.hadoop.hive.ql.IDriver in project hive by apache.
the class TestHiveTestEnvSetup method testMappingSameQuery.
@Test
public void testMappingSameQuery() throws ParseException, Exception {
IDriver driver = createDriver();
String query = "select sum(u*u),sum(u) from tu where u>1";
CommandProcessorResponse ret = driver.run(query);
assertEquals(0, ret.getResponseCode());
List res = new ArrayList();
driver.getFetchTask().fetch(res);
System.out.println(res);
assertEquals(1, res.size());
assertEquals("13\t5", res.get(0));
}
use of org.apache.hadoop.hive.ql.IDriver in project hive by apache.
the class TestHiveTestEnvSetup method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
IDriver driver = createDriver();
dropTables(driver);
String[] cmds = { // @formatter:off
"create table tu(u int)", "insert into tu values (1),(2),(3)" // @formatter:on
};
for (String cmd : cmds) {
int ret = driver.run(cmd).getResponseCode();
assertEquals("Checking command success", 0, ret);
}
}
use of org.apache.hadoop.hive.ql.IDriver in project hive by apache.
the class TestHiveTestEnvSetup method createDriver.
private static IDriver createDriver() {
HiveConf conf = env_setup.getTestCtx().hiveConf;
conf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
HiveConf.setBoolVar(conf, HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
SessionState.start(conf);
IDriver driver = DriverFactory.newDriver(conf);
return driver;
}
use of org.apache.hadoop.hive.ql.IDriver in project hive by apache.
the class TestCounterMapping method createDriver.
private static IDriver createDriver() {
// HiveConf conf = new HiveConf(Driver.class);
HiveConf conf = env_setup.getTestCtx().hiveConf;
conf.setBoolVar(ConfVars.HIVE_QUERY_REEXECUTION_ENABLED, true);
conf.setBoolVar(ConfVars.HIVE_QUERY_REEXECUTION_ALWAYS_COLLECT_OPERATOR_STATS, true);
conf.set("hive.auto.convert.join", "false");
conf.set("hive.optimize.ppd", "false");
conf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
// conf.setVar(HiveConf.ConfVars.SEMANTIC_ANALYZER_HOOK, CheckInputReadEntityDirect.class.getName());
HiveConf.setBoolVar(conf, HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
HiveConf.setVar(conf, HiveConf.ConfVars.POSTEXECHOOKS, OperatorStatsReaderHook.class.getName());
SessionState.start(conf);
IDriver driver = DriverFactory.newDriver(conf);
return driver;
}
Aggregations