Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7452#discussion_r34830499
  
    --- 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 --
    
    Actually we didn't enable this test suite before... `compareConditions` 
just return a boolean but we don't have any assertions here. However, I think 
we should use `comparePlans` directly as it provide better error message.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to