Search in sources :

Example 1 with IDriver

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");
}
Also used : CommandProcessorResponse(org.apache.hadoop.hive.ql.processors.CommandProcessorResponse) IDriver(org.apache.hadoop.hive.ql.IDriver) HiveConf(org.apache.hadoop.hive.conf.HiveConf)

Example 2 with IDriver

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));
}
Also used : CommandProcessorResponse(org.apache.hadoop.hive.ql.processors.CommandProcessorResponse) ArrayList(java.util.ArrayList) IDriver(org.apache.hadoop.hive.ql.IDriver) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 3 with IDriver

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);
    }
}
Also used : IDriver(org.apache.hadoop.hive.ql.IDriver) BeforeClass(org.junit.BeforeClass)

Example 4 with IDriver

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;
}
Also used : IDriver(org.apache.hadoop.hive.ql.IDriver) HiveConf(org.apache.hadoop.hive.conf.HiveConf)

Example 5 with IDriver

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;
}
Also used : IDriver(org.apache.hadoop.hive.ql.IDriver) HiveConf(org.apache.hadoop.hive.conf.HiveConf) OperatorStatsReaderHook(org.apache.hadoop.hive.ql.stats.OperatorStatsReaderHook)

Aggregations

IDriver (org.apache.hadoop.hive.ql.IDriver)29 Test (org.junit.Test)11 PlanMapper (org.apache.hadoop.hive.ql.plan.mapper.PlanMapper)10 HiveConf (org.apache.hadoop.hive.conf.HiveConf)7 FilterOperator (org.apache.hadoop.hive.ql.exec.FilterOperator)5 CommandProcessorResponse (org.apache.hadoop.hive.ql.processors.CommandProcessorResponse)4 AfterClass (org.junit.AfterClass)4 BeforeClass (org.junit.BeforeClass)4 PrintStream (java.io.PrintStream)3 ArrayList (java.util.ArrayList)3 CliSessionState (org.apache.hadoop.hive.cli.CliSessionState)3 LinkGroup (org.apache.hadoop.hive.ql.plan.mapper.PlanMapper.LinkGroup)3 OperatorStatsReaderHook (org.apache.hadoop.hive.ql.stats.OperatorStatsReaderHook)3 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 LogInitializationException (org.apache.hadoop.hive.common.LogUtils.LogInitializationException)2 OperatorStats (org.apache.hadoop.hive.ql.stats.OperatorStats)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 SQLException (java.sql.SQLException)1