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);
}
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);
}
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;
}
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;
}
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);
}
Aggregations