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