wangyum commented on a change in pull request #27252: [SPARK-29231][SQL] 
Constraints should be inferred from cast equality constraint
URL: https://github.com/apache/spark/pull/27252#discussion_r377446880
 
 

 ##########
 File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/InferFiltersFromConstraintsSuite.scala
 ##########
 @@ -263,4 +264,34 @@ class InferFiltersFromConstraintsSuite extends PlanTest {
     val y = testRelation.subquery('y)
     testConstraintsAfterJoin(x, y, x.where(IsNotNull('a)), y, RightOuter)
   }
+
+  test("Constraints should be inferred from cast equality constraint(filter 
higher data type)") {
+    val testRelation1 = LocalRelation('a.int)
+    val testRelation2 = LocalRelation('b.long)
+    val originalLeft = testRelation1.subquery('left)
+    val originalRight = testRelation2.where('b === 1L).subquery('right)
+
+    val left = testRelation1.where(IsNotNull('a) && 'a.cast(LongType) === 
1L).subquery('left)
+    val right = testRelation2.where(IsNotNull('b) && 'b === 
1L).subquery('right)
+
+    Seq(Some("left.a".attr.cast(LongType) === "right.b".attr),
+      Some("right.b".attr === "left.a".attr.cast(LongType))).foreach { 
condition =>
+      testConstraintsAfterJoin(originalLeft, originalRight, left, right, 
Inner, condition)
+    }
+  }
+
+  test("Constraints shouldn't be inferred from cast equality constraint(filter 
lower data type)") {
+    val testRelation1 = LocalRelation('a.int)
+    val testRelation2 = LocalRelation('b.long)
 
 Review comment:
   Yes. 
https://github.com/apache/spark/pull/27252/commits/8dcd076ba1843289b5775abe002ff0d88f235d8f

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to