Search in sources :

Example 6 with IDriver

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

the class TestCounterMapping method testMappingJoinLookup.

@Test
@Ignore("needs HiveFilter mapping")
public void testMappingJoinLookup() throws ParseException {
    IDriver driver = createDriver();
    PlanMapper pm0 = getMapperForQuery(driver, "select sum(tu.id_uv),sum(u) from tu join tv on (tu.id_uv = tv.id_uv) where u>1 and v>1");
    Iterator<LinkGroup> itG = pm0.iterateGroups();
    int checkedOperators = 0;
    while (itG.hasNext()) {
        LinkGroup g = itG.next();
        List<HiveFilter> hfs = g.getAll(HiveFilter.class);
        List<OperatorStats> oss = g.getAll(OperatorStats.class);
        List<FilterOperator> fos = g.getAll(FilterOperator.class);
        if (fos.size() > 0 && oss.size() > 0) {
            if (hfs.size() == 0) {
                fail("HiveFilter is not connected?");
            }
            OperatorStats os = oss.get(0);
            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) HiveFilter(org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveFilter) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with IDriver

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

the class TestOperatorCmp method testDifferentFiltersAreNotMatched1.

@Test
public void testDifferentFiltersAreNotMatched1() 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 u from tu where id_uv = 2 group by u");
    assertHelper(AssertHelperOp.SAME, pm0, pm1, TableScanOperator.class);
    assertHelper(AssertHelperOp.NOT_SAME, pm0, pm1, FilterOperator.class);
}
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 IDriver

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

the class TestOperatorCmp method testUnrelatedFiltersAreNotMatched0.

@Test
public void testUnrelatedFiltersAreNotMatched0() throws ParseException {
    IDriver driver = createDriver();
    String query = "select u from tu where id_uv = 1 union all select v from tv where id_uv = 1";
    PlanMapper pm = getMapperForQuery(driver, query);
    Iterator<LinkGroup> itG = pm.iterateGroups();
    List<FilterOperator> fos = pm.getAll(FilterOperator.class);
    assertEquals(2, fos.size());
    assertFalse("logicalEquals", compareOperators(fos.get(0), fos.get(1)));
}
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) Test(org.junit.Test)

Example 9 with IDriver

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

the class TestOperatorCmp method testSameFiltersMatched1.

@Test
public void testSameFiltersMatched1() throws ParseException, Exception {
    IDriver driver = createDriver();
    PlanMapper pm0 = getMapperForQuery(driver, "select u from tu where id_uv = 1 group by u");
    PlanMapper pm1 = getMapperForQuery(driver, "select u from tu where id_uv = 1 group by u");
    assertHelper(AssertHelperOp.SAME, pm0, pm1, FilterOperator.class);
    assertHelper(AssertHelperOp.SAME, pm0, pm1, TableScanOperator.class);
}
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 IDriver

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

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