use of org.apache.hadoop.hive.ql.plan.mapper.PlanMapper in project hive by apache.
the class TestCounterMapping method getMapperForQuery.
private PlanMapper getMapperForQuery(IDriver driver, String query) throws CommandProcessorException {
driver.run(query);
PlanMapper pm0 = driver.getContext().getPlanMapper();
return pm0;
}
use of org.apache.hadoop.hive.ql.plan.mapper.PlanMapper in project hive by apache.
the class TestCounterMapping method testUsageOfRuntimeInfo.
@Test
public void testUsageOfRuntimeInfo() throws ParseException, CommandProcessorException {
IDriver driver = createDriver();
String query = "select sum(u) from tu where u>1";
PlanMapper pm1 = getMapperForQuery(driver, query);
List<FilterOperator> filters1 = pm1.getAll(FilterOperator.class);
filters1.sort(OPERATOR_ID_COMPARATOR.reversed());
FilterOperator filter1 = filters1.get(0);
driver = createDriver();
((ReExecDriver) driver).setStatsSource(StatsSources.getStatsSourceContaining(EmptyStatsSource.INSTANCE, pm1));
PlanMapper pm2 = getMapperForQuery(driver, query);
List<FilterOperator> filters2 = pm2.getAll(FilterOperator.class);
filters2.sort(OPERATOR_ID_COMPARATOR.reversed());
FilterOperator filter2 = filters2.get(0);
assertEquals("original check", 7, filter1.getStatistics().getNumRows());
assertEquals("optimized check", 6, filter2.getStatistics().getNumRows());
}
use of org.apache.hadoop.hive.ql.plan.mapper.PlanMapper 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);
}
use of org.apache.hadoop.hive.ql.plan.mapper.PlanMapper 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);
}
use of org.apache.hadoop.hive.ql.plan.mapper.PlanMapper 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());
}
Aggregations