From 808835f3d41c5534bdc5d531402fb11fbc39963c Mon Sep 17 00:00:00 2001 From: Jianfeng Jia Date: Wed, 31 Aug 2016 00:33:59 -0700 Subject: [PATCH 1/2] remove the unnessary string check in view --- .../edu/uci/ics/cloudberry/zion/model/impl/QueryPlanner.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zion/src/main/scala/edu/uci/ics/cloudberry/zion/model/impl/QueryPlanner.scala b/zion/src/main/scala/edu/uci/ics/cloudberry/zion/model/impl/QueryPlanner.scala index f4908ff14..6c395f6aa 100644 --- a/zion/src/main/scala/edu/uci/ics/cloudberry/zion/model/impl/QueryPlanner.scala +++ b/zion/src/main/scala/edu/uci/ics/cloudberry/zion/model/impl/QueryPlanner.scala @@ -56,7 +56,9 @@ class QueryPlanner { //TODO if select project fields from groupby results, postpone the project to the merge stage. //TODO here is a very simple assumption that the schema is the same, what if the schema are different? - seqBuilder += query.copy(dataset = view.name) + val viewFilters = view.createQueryOpt.get.filter + val newFilter = query.filter.filterNot(qf => viewFilters.exists(vf => vf.covers(qf, source.schema.fieldMap(qf.fieldName).dataType))) + seqBuilder += query.copy(dataset = view.name, filter = newFilter) for (interval <- unCovered) { seqBuilder += query.setInterval(source.schema.timeField, interval) } From 688bb6a26b8b181d7cc317ecf2449b97db40f980 Mon Sep 17 00:00:00 2001 From: Jianfeng Jia Date: Wed, 31 Aug 2016 01:09:58 -0700 Subject: [PATCH 2/2] add test case --- .../uci/ics/cloudberry/zion/model/impl/QueryPlanner.scala | 2 +- .../ics/cloudberry/zion/model/impl/QueryPlannerTest.scala | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/zion/src/main/scala/edu/uci/ics/cloudberry/zion/model/impl/QueryPlanner.scala b/zion/src/main/scala/edu/uci/ics/cloudberry/zion/model/impl/QueryPlanner.scala index 6c395f6aa..93c69cf98 100644 --- a/zion/src/main/scala/edu/uci/ics/cloudberry/zion/model/impl/QueryPlanner.scala +++ b/zion/src/main/scala/edu/uci/ics/cloudberry/zion/model/impl/QueryPlanner.scala @@ -57,7 +57,7 @@ class QueryPlanner { //TODO here is a very simple assumption that the schema is the same, what if the schema are different? val viewFilters = view.createQueryOpt.get.filter - val newFilter = query.filter.filterNot(qf => viewFilters.exists(vf => vf.covers(qf, source.schema.fieldMap(qf.fieldName).dataType))) + val newFilter = query.filter.filterNot(qf => viewFilters.exists(vf => qf.covers(vf, source.schema.fieldMap(qf.fieldName).dataType))) seqBuilder += query.copy(dataset = view.name, filter = newFilter) for (interval <- unCovered) { seqBuilder += query.setInterval(source.schema.timeField, interval) diff --git a/zion/src/test/scala/edu/uci/ics/cloudberry/zion/model/impl/QueryPlannerTest.scala b/zion/src/test/scala/edu/uci/ics/cloudberry/zion/model/impl/QueryPlannerTest.scala index 42ddd35b0..94787fec5 100644 --- a/zion/src/test/scala/edu/uci/ics/cloudberry/zion/model/impl/QueryPlannerTest.scala +++ b/zion/src/test/scala/edu/uci/ics/cloudberry/zion/model/impl/QueryPlannerTest.scala @@ -47,6 +47,12 @@ class QueryPlannerTest extends Specification { queries.size must_== 1 queries.head must_== queryCount.copy(dataset = zikaFullYearViewInfo.name) } + "makePlan should omit the redundant filter from query if it covers view.createQuery" in { + val queryZika = Query(dataset = TwitterDataSet, filter = Seq(FilterStatement("text", None, Relation.contains, Seq("zika"))), groups = Some(group)) + val (queries, _) = planner.makePlan(queryZika, sourceInfo, Seq(zikaFullYearViewInfo)) + queries.size must_== 1 + queries.head must_== Query(dataset = zikaFullYearViewInfo.name, groups = Some(group)) + } "makePlan should ask the view and the source if view can not cover the query" in { val (queries, _) = planner.makePlan(queryCount, sourceInfo, Seq(zikaHalfYearViewInfo)) queries.size must_== 2