Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19451#discussion_r147510054
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/ReplaceOperatorSuite.scala
 ---
    @@ -50,6 +52,108 @@ class ReplaceOperatorSuite extends PlanTest {
         comparePlans(optimized, correctAnswer)
       }
     
    +  test("replace Except with Filter while both the nodes are of type 
Filter") {
    +    val attributeA = 'a.int
    +    val attributeB = 'b.int
    +
    +    val table1 = LocalRelation.fromExternalRows(Seq(attributeA, 
attributeB), data = Seq(Row(1, 2)))
    +    val table2 = Filter(attributeB === 2, Filter(attributeA === 1, table1))
    +    val table3 = Filter(attributeB < 1, Filter(attributeA >= 2, table1))
    +
    +    val query = Except(table2, table3)
    +    val optimized = Optimize.execute(query.analyze)
    +
    +    val correctAnswer =
    +      Aggregate(table1.output, table1.output,
    +        Filter(Not((attributeA.isNotNull && attributeB.isNotNull) &&
    +          (attributeA >= 2 && attributeB < 1)),
    +          Filter(attributeB === 2, Filter(attributeA === 1, 
table1)))).analyze
    +
    +    comparePlans(optimized, correctAnswer)
    +  }
    +
    +  test("replace Except with Filter while only right node is of type 
Filter") {
    +    val attributeA = 'a.int
    +    val attributeB = 'b.int
    +
    +    val table1 = LocalRelation.fromExternalRows(Seq(attributeA, 
attributeB), data = Seq(Row(1, 2)))
    +    val table2 = Filter(attributeB < 1, Filter(attributeA >= 2, table1))
    +
    +    val query = Except(table1, table2)
    +    val optimized = Optimize.execute(query.analyze)
    +
    +    val correctAnswer =
    +      Aggregate(table1.output, table1.output,
    +        Filter(Not((attributeA.isNotNull && attributeB.isNotNull) &&
    +          (attributeA >= 2 && attributeB < 1)), table1)).analyze
    +
    +    comparePlans(optimized, correctAnswer)
    +  }
    +
    +  test("replace Except with Filter while both the nodes are of type 
Project") {
    +    val attributeA = 'a.int
    +    val attributeB = 'b.int
    +
    +    val table1 = LocalRelation.fromExternalRows(Seq(attributeA, 
attributeB), data = Seq(Row(1, 2)))
    +    val table2 = Project(Seq(attributeA, attributeB), table1)
    +    val table3 = Project(Seq(attributeA, attributeB),
    +      Filter(attributeB < 1, Filter(attributeA >= 2, table1)))
    +
    +    val query = Except(table2, table3)
    +    val optimized = Optimize.execute(query.analyze)
    +
    +    val correctAnswer =
    +      Aggregate(table1.output, table1.output,
    +        Filter(Not((attributeA.isNotNull && attributeB.isNotNull)
    +          && (attributeA >= 2 && attributeB < 1)),
    --- End diff --
    
    Move `&& ` to the end of line 107


---

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

Reply via email to