Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
JavierJia committed Aug 31, 2016
1 parent 808835f commit 688bb6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 688bb6a

Please sign in to comment.