Search in sources :

Example 11 with IDriver

use of org.apache.hadoop.hive.ql.IDriver in project hive by apache.

the class TestOperatorCmp method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    IDriver driver = createDriver();
    dropTables(driver);
    String[] cmds = { // @formatter:off
    "create table tu(id_uv int,id_uw int,u int)", "create table tv(id_uv int,v int)", "create table tw(id_uw int,w int)", "insert into tu values (10,10,10),(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),(6,6,6)", "insert into tv values (10,10),(1,1),(2,2),(3,3)", "insert into tw values (10,10),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9)" // @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 12 with IDriver

use of org.apache.hadoop.hive.ql.IDriver in project hive by apache.

the class TestReOptimization method afterClass.

@AfterClass
public static void afterClass() throws Exception {
    IDriver driver = createDriver("");
    dropTables(driver);
}
Also used : IDriver(org.apache.hadoop.hive.ql.IDriver) AfterClass(org.junit.AfterClass)

Example 13 with IDriver

use of org.apache.hadoop.hive.ql.IDriver in project hive by apache.

the class TestReOptimization method testReExecutedIfMapJoinError.

@Test
public void testReExecutedIfMapJoinError() throws Exception {
    IDriver driver = createDriver("overlay,reoptimize");
    String query = "select assert_true_oom(${hiveconf:zzz}>sum(1)) from tu join tv on (tu.id_uv=tv.id_uv) where u<10 and v>1";
    PlanMapper pm = getMapperForQuery(driver, query);
}
Also used : PlanMapper(org.apache.hadoop.hive.ql.plan.mapper.PlanMapper) IDriver(org.apache.hadoop.hive.ql.IDriver) Test(org.junit.Test)

Example 14 with IDriver

use of org.apache.hadoop.hive.ql.IDriver in project hive by apache.

the class TestReOptimization method testStatsAreSetInReopt.

@Test
public void testStatsAreSetInReopt() throws Exception {
    IDriver driver = createDriver("overlay,reoptimize");
    String query = "select assert_true_oom(${hiveconf:zzz} > sum(u*v)) from tu join tv on (tu.id_uv=tv.id_uv) where u<10 and v>1";
    PlanMapper pm = getMapperForQuery(driver, query);
    Iterator<LinkGroup> itG = pm.iterateGroups();
    int checkedOperators = 0;
    while (itG.hasNext()) {
        LinkGroup g = itG.next();
        List<FilterOperator> fos = g.getAll(FilterOperator.class);
        List<OperatorStats> oss = g.getAll(OperatorStats.class);
        if (fos.size() > 0 && oss.size() > 0) {
            fos.sort(TestCounterMapping.OPERATOR_ID_COMPARATOR.reversed());
            FilterOperator fo = fos.get(0);
            OperatorStats os = oss.get(0);
            Statistics stats = fo.getStatistics();
            assertEquals(os.getOutputRecords(), stats.getNumRows());
            if (!(os.getOutputRecords() == 3 || os.getOutputRecords() == 6)) {
                fail("nonexpected number of records produced");
            }
            checkedOperators++;
        }
    }
    assertEquals(2, checkedOperators);
}
Also used : FilterOperator(org.apache.hadoop.hive.ql.exec.FilterOperator) PlanMapper(org.apache.hadoop.hive.ql.plan.mapper.PlanMapper) IDriver(org.apache.hadoop.hive.ql.IDriver) LinkGroup(org.apache.hadoop.hive.ql.plan.mapper.PlanMapper.LinkGroup) OperatorStats(org.apache.hadoop.hive.ql.stats.OperatorStats) Statistics(org.apache.hadoop.hive.ql.plan.Statistics) Test(org.junit.Test)

Example 15 with IDriver

use of org.apache.hadoop.hive.ql.IDriver in project hive by apache.

the class TestReOptimization method testNotReExecutedIfAssertionError.

@Test(expected = CommandProcessorResponse.class)
public void testNotReExecutedIfAssertionError() throws Exception {
    IDriver driver = createDriver("reoptimize");
    String query = "select assert_true(${hiveconf:zzz}>sum(1)) from tu join tv on (tu.id_uv=tv.id_uv) where u<10 and v>1";
    PlanMapper pm = getMapperForQuery(driver, query);
    assertEquals(1, driver.getContext().getExecutionIndex());
}
Also used : PlanMapper(org.apache.hadoop.hive.ql.plan.mapper.PlanMapper) IDriver(org.apache.hadoop.hive.ql.IDriver) Test(org.junit.Test)

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