Search in sources :

Example 31 with FilterOperator

use of org.apache.hadoop.hive.ql.exec.FilterOperator in project hive by apache.

the class TestCounterMapping method testBreakupAnd.

@Test
public void testBreakupAnd() throws ParseException, CommandProcessorException {
    String query = "explain select sum(id_uv) from tu where u=1  and (u=2 or u=1) group by u";
    IDriver driver = createDriver();
    PlanMapper pm = getMapperForQuery(driver, query);
    List<FilterOperator> fos = pm.getAll(FilterOperator.class);
    OpTreeSignature filterSig = pm.lookup(OpTreeSignature.class, fos.get(0));
    Object pred = filterSig.getSig().getSigMap().get("getPredicateString");
    assertEquals("(u = 1) (type: boolean)", pred);
}
Also used : FilterOperator(org.apache.hadoop.hive.ql.exec.FilterOperator) OpTreeSignature(org.apache.hadoop.hive.ql.optimizer.signature.OpTreeSignature) PlanMapper(org.apache.hadoop.hive.ql.plan.mapper.PlanMapper) IDriver(org.apache.hadoop.hive.ql.IDriver) Test(org.junit.Test)

Example 32 with FilterOperator

use of org.apache.hadoop.hive.ql.exec.FilterOperator in project hive by apache.

the class TestReOptimization method testReOptimizationCanSendBackStatsToCBO.

@Test
public void testReOptimizationCanSendBackStatsToCBO() throws Exception {
    IDriver driver = createDriver("overlay,reoptimize");
    // @formatter:off
    String query = "select assert_true_oom(${hiveconf:zzz} > sum(u*v*w)) from tu\n" + "        join tv on (tu.id_uv=tv.id_uv)\n" + "        join tw on (tu.id_uw=tw.id_uw)\n" + "        where w>9 and u>1 and v>3";
    // @formatter:on
    PlanMapper pm = getMapperForQuery(driver, query);
    Iterator<EquivGroup> itG = pm.iterateGroups();
    int checkedOperators = 0;
    while (itG.hasNext()) {
        EquivGroup g = itG.next();
        List<FilterOperator> fos = g.getAll(FilterOperator.class);
        List<OperatorStats> oss = g.getAll(OperatorStats.class);
        List<HiveFilter> hfs = g.getAll(HiveFilter.class);
        if (fos.size() > 0 && oss.size() > 0 && hfs.size() > 0) {
            fos.sort(TestCounterMapping.OPERATOR_ID_COMPARATOR.reversed());
            HiveFilter hf = hfs.get(0);
            FilterOperator fo = fos.get(0);
            OperatorStats os = oss.get(0);
            long cntFilter = RelMetadataQuery.instance().getRowCount(hf).longValue();
            if (fo.getStatistics() != null) {
            // in case the join order is changed the subTree-s are not matching anymore because an RS is present in the condition
            // assertEquals(os.getOutputRecords(), fo.getStatistics().getNumRows());
            }
            assertEquals(os.getOutputRecords(), cntFilter);
            checkedOperators++;
        }
    }
    assertEquals(3, checkedOperators);
}
Also used : PlanMapper(org.apache.hadoop.hive.ql.plan.mapper.PlanMapper) OperatorStats(org.apache.hadoop.hive.ql.stats.OperatorStats) HiveFilter(org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveFilter) FilterOperator(org.apache.hadoop.hive.ql.exec.FilterOperator) IDriver(org.apache.hadoop.hive.ql.IDriver) EquivGroup(org.apache.hadoop.hive.ql.plan.mapper.PlanMapper.EquivGroup) Test(org.junit.Test)

Example 33 with FilterOperator

use of org.apache.hadoop.hive.ql.exec.FilterOperator in project hive by apache.

the class TestStatEstimations method testFilterStringIn.

@Test
public void testFilterStringIn() throws ParseException, CommandProcessorException {
    IDriver driver = createDriver();
    String query = "explain select a from t2 where b IN ('A3', 'ABC', 'AXZ') order by a";
    PlanMapper pm = getMapperForQuery(driver, query);
    List<FilterOperator> fos = pm.getAll(FilterOperator.class);
    // the same operator is present 2 times
    fos.sort(TestCounterMapping.OPERATOR_ID_COMPARATOR.reversed());
    FilterOperator fop = fos.get(0);
    // any estimation near 1 is ok...currently 1
    assertEquals(1, fop.getStatistics().getNumRows());
}
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 34 with FilterOperator

use of org.apache.hadoop.hive.ql.exec.FilterOperator in project hive by apache.

the class TestStatEstimations method testFilterStringNotIn.

// FIXME: right now not in is transformed into AND( NE(...) , NE(...) )
@Ignore
@Test
public void testFilterStringNotIn() throws CommandProcessorException {
    IDriver driver = createDriver();
    String query = "explain select a from t2 where b NOT IN ('XXX', 'UUU') order by a";
    PlanMapper pm = getMapperForQuery(driver, query);
    List<FilterOperator> fos = pm.getAll(FilterOperator.class);
    // the same operator is present 2 times
    fos.sort(TestCounterMapping.OPERATOR_ID_COMPARATOR.reversed());
    assertEquals(1, fos.size());
    FilterOperator fop = fos.get(0);
    // any estimation near 10 is ok...currently 10
    assertEquals(10, fop.getStatistics().getNumRows());
}
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) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

FilterOperator (org.apache.hadoop.hive.ql.exec.FilterOperator)34 ExprNodeDesc (org.apache.hadoop.hive.ql.plan.ExprNodeDesc)16 TableScanOperator (org.apache.hadoop.hive.ql.exec.TableScanOperator)13 IDriver (org.apache.hadoop.hive.ql.IDriver)12 ReduceSinkOperator (org.apache.hadoop.hive.ql.exec.ReduceSinkOperator)12 FilterDesc (org.apache.hadoop.hive.ql.plan.FilterDesc)12 PlanMapper (org.apache.hadoop.hive.ql.plan.mapper.PlanMapper)12 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)10 Operator (org.apache.hadoop.hive.ql.exec.Operator)10 RowSchema (org.apache.hadoop.hive.ql.exec.RowSchema)9 UnionOperator (org.apache.hadoop.hive.ql.exec.UnionOperator)9 List (java.util.List)6 AppMasterEventOperator (org.apache.hadoop.hive.ql.exec.AppMasterEventOperator)6 DummyStoreOperator (org.apache.hadoop.hive.ql.exec.DummyStoreOperator)6 JoinOperator (org.apache.hadoop.hive.ql.exec.JoinOperator)6 MapJoinOperator (org.apache.hadoop.hive.ql.exec.MapJoinOperator)6 ExprNodeColumnDesc (org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc)6 ExprNodeGenericFuncDesc (org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc)6 HashMap (java.util.HashMap)5