Search in sources :

Example 1 with PlanMapper

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

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

Example 4 with PlanMapper

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

the class StatsRulesProcFactory method applyRuntimeStats.

private static Statistics applyRuntimeStats(Context context, Statistics stats, Operator<?> op) {
    if (!((HiveConf) context.getConf()).getBoolVar(ConfVars.HIVE_QUERY_REEXECUTION_ENABLED)) {
        return stats;
    }
    PlanMapper pm = context.getPlanMapper();
    OpTreeSignature treeSig = pm.getSignatureOf(op);
    pm.link(op, treeSig);
    StatsSource statsSource = context.getStatsSource();
    if (!statsSource.canProvideStatsFor(op.getClass())) {
        return stats;
    }
    Optional<OperatorStats> os = statsSource.lookup(treeSig);
    if (!os.isPresent()) {
        return stats;
    }
    LOG.debug("using runtime stats for {}; {}", op, os.get());
    Statistics outStats = stats.clone();
    outStats = outStats.scaleToRowCount(os.get().getOutputRecords(), false);
    outStats.setRuntimeStats(true);
    return outStats;
}
Also used : OpTreeSignature(org.apache.hadoop.hive.ql.optimizer.signature.OpTreeSignature) PlanMapper(org.apache.hadoop.hive.ql.plan.mapper.PlanMapper) OperatorStats(org.apache.hadoop.hive.ql.stats.OperatorStats) Statistics(org.apache.hadoop.hive.ql.plan.Statistics) ColStatistics(org.apache.hadoop.hive.ql.plan.ColStatistics) StatsSource(org.apache.hadoop.hive.ql.plan.mapper.StatsSource)

Example 5 with PlanMapper

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

the class TestCounterMapping method testBreakupAnd2.

@Test
public void testBreakupAnd2() throws ParseException, CommandProcessorException {
    String query = "explain select sum(id_uv) from tu where u in (1,2,3) and u=2 and u=2 and 2=u 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 = 2) (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)

Aggregations

PlanMapper (org.apache.hadoop.hive.ql.plan.mapper.PlanMapper)26 IDriver (org.apache.hadoop.hive.ql.IDriver)17 Test (org.junit.Test)17 FilterOperator (org.apache.hadoop.hive.ql.exec.FilterOperator)12 OpTreeSignature (org.apache.hadoop.hive.ql.optimizer.signature.OpTreeSignature)5 OperatorStats (org.apache.hadoop.hive.ql.stats.OperatorStats)4 Statistics (org.apache.hadoop.hive.ql.plan.Statistics)3 EquivGroup (org.apache.hadoop.hive.ql.plan.mapper.PlanMapper.EquivGroup)3 HiveFilter (org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveFilter)2 CommandProcessorResponse (org.apache.hadoop.hive.ql.processors.CommandProcessorResponse)2 Ignore (org.junit.Ignore)2 IOException (java.io.IOException)1 HiveConf (org.apache.hadoop.hive.conf.HiveConf)1 CommonJoinOperator (org.apache.hadoop.hive.ql.exec.CommonJoinOperator)1 ColStatistics (org.apache.hadoop.hive.ql.plan.ColStatistics)1 SimpleRuntimeStatsSource (org.apache.hadoop.hive.ql.plan.mapper.SimpleRuntimeStatsSource)1 StatsSource (org.apache.hadoop.hive.ql.plan.mapper.StatsSource)1 CommandProcessorException (org.apache.hadoop.hive.ql.processors.CommandProcessorException)1 ReExecDriver (org.apache.hadoop.hive.ql.reexec.ReExecDriver)1