Search in sources :

Example 6 with PlanMapper

use of org.apache.hadoop.hive.ql.plan.mapper.PlanMapper in project hive by apache.

the class TestOperatorCmp method testUnrelatedFiltersAreNotMatched1.

@Test
public void testUnrelatedFiltersAreNotMatched1() throws ParseException {
    IDriver driver = createDriver();
    PlanMapper pm0 = getMapperForQuery(driver, "select u from tu where id_uv = 1 group by u");
    PlanMapper pm1 = getMapperForQuery(driver, "select v from tv where id_uv = 1 group by v");
    List<FilterOperator> fos0 = pm0.getAll(FilterOperator.class);
    List<FilterOperator> fos1 = pm1.getAll(FilterOperator.class);
    assertEquals(1, fos0.size());
    assertEquals(1, fos1.size());
    assertFalse("logicalEquals", compareOperators(fos0.get(0), fos1.get(0)));
}
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) Test(org.junit.Test)

Example 7 with PlanMapper

use of org.apache.hadoop.hive.ql.plan.mapper.PlanMapper 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 8 with PlanMapper

use of org.apache.hadoop.hive.ql.plan.mapper.PlanMapper 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 9 with PlanMapper

use of org.apache.hadoop.hive.ql.plan.mapper.PlanMapper 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)

Example 10 with PlanMapper

use of org.apache.hadoop.hive.ql.plan.mapper.PlanMapper in project hive by apache.

the class TestReOptimization method getMapperForQuery.

private PlanMapper getMapperForQuery(IDriver driver, String query) throws CommandProcessorResponse {
    CommandProcessorResponse res = driver.run(query);
    if (res.getResponseCode() != 0) {
        throw res;
    }
    PlanMapper pm0 = driver.getContext().getPlanMapper();
    return pm0;
}
Also used : CommandProcessorResponse(org.apache.hadoop.hive.ql.processors.CommandProcessorResponse) PlanMapper(org.apache.hadoop.hive.ql.plan.mapper.PlanMapper)

Aggregations

PlanMapper (org.apache.hadoop.hive.ql.plan.mapper.PlanMapper)15 IDriver (org.apache.hadoop.hive.ql.IDriver)10 Test (org.junit.Test)10 FilterOperator (org.apache.hadoop.hive.ql.exec.FilterOperator)5 LinkGroup (org.apache.hadoop.hive.ql.plan.mapper.PlanMapper.LinkGroup)3 SimpleRuntimeStatsSource (org.apache.hadoop.hive.ql.plan.mapper.SimpleRuntimeStatsSource)2 CommandProcessorResponse (org.apache.hadoop.hive.ql.processors.CommandProcessorResponse)2 OperatorStats (org.apache.hadoop.hive.ql.stats.OperatorStats)2 ArrayList (java.util.ArrayList)1 HiveFilter (org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveFilter)1 Statistics (org.apache.hadoop.hive.ql.plan.Statistics)1 ReExecDriver (org.apache.hadoop.hive.ql.reexec.ReExecDriver)1 Ignore (org.junit.Ignore)1