Skip to content

Commit

Permalink
Remove the unnessary string check in view (#184)
Browse files Browse the repository at this point in the history
* remove the unnecessary string check in view
  • Loading branch information
JavierJia authored Aug 31, 2016
2 parents e3837bc + 0915127 commit 099c44a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 => 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 099c44a

Please sign in to comment.