Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove redundant conditions while combining filters
  • Loading branch information
sameeragarwal committed Mar 12, 2016
commit c78166de38f48b11f8e3dc328c95f80451206f7c
Original file line number Diff line number Diff line change
Expand Up @@ -819,12 +819,15 @@ object CombineUnions extends Rule[LogicalPlan] {
}

/**
* Combines two adjacent [[Filter]] operators into one, merging the
* conditions into one conjunctive predicate.
* Combines two adjacent [[Filter]] operators into one, merging the non-redundant conditions into
* one conjunctive predicate.
*/
object CombineFilters extends Rule[LogicalPlan] {
object CombineFilters extends Rule[LogicalPlan] with PredicateHelper {
def apply(plan: LogicalPlan): LogicalPlan = plan transform {
case ff @ Filter(fc, nf @ Filter(nc, grandChild)) => Filter(And(nc, fc), grandChild)
case ff @ Filter(fc, nf @ Filter(nc, grandChild)) =>
val ac = (ExpressionSet(splitConjunctivePredicates(nc)) --
ExpressionSet(splitConjunctivePredicates(fc))).reduce(And)
Filter(And(ac, fc), grandChild)
}
}

Expand Down