Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/7452#discussion_r34939389
--- Diff:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/BooleanSimplificationSuite.scala
---
@@ -40,29 +40,11 @@ class BooleanSimplificationSuite extends PlanTest with
PredicateHelper {
val testRelation = LocalRelation('a.int, 'b.int, 'c.int, 'd.string)
- // The `foldLeft` is required to handle cases like comparing `a && (b &&
c)` and `(a && b) && c`
- def compareConditions(e1: Expression, e2: Expression): Boolean = (e1,
e2) match {
- case (lhs: And, rhs: And) =>
- val lhsSet = splitConjunctivePredicates(lhs).toSet
- val rhsSet = splitConjunctivePredicates(rhs).toSet
- lhsSet.foldLeft(rhsSet) { (set, e) =>
- set.find(compareConditions(_, e)).map(set - _).getOrElse(set)
- }.isEmpty
-
- case (lhs: Or, rhs: Or) =>
- val lhsSet = splitDisjunctivePredicates(lhs).toSet
- val rhsSet = splitDisjunctivePredicates(rhs).toSet
- lhsSet.foldLeft(rhsSet) { (set, e) =>
- set.find(compareConditions(_, e)).map(set - _).getOrElse(set)
- }.isEmpty
-
- case (l, r) => l == r
- }
-
def checkCondition(input: Expression, expected: Expression): Unit = {
val plan = testRelation.where(input).analyze
- val actual = Optimize.execute(plan).expressions.head
- compareConditions(actual, expected)
+ val actual = Optimize.execute(plan)
+ val correctAnswer = testRelation.where(expected).analyze
+ comparePlans(actual, correctAnswer)
--- End diff --
Good catch!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]