wangyum commented on a change in pull request #28642:
URL: https://github.com/apache/spark/pull/28642#discussion_r435725708



##########
File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/InferFiltersFromConstraintsSuite.scala
##########
@@ -316,4 +316,19 @@ class InferFiltersFromConstraintsSuite extends PlanTest {
         condition)
     }
   }
+
+  test("Infer IsNotNull for non null-intolerant child of null intolerant join 
condition") {
+    testConstraintsAfterJoin(
+      testRelation.subquery('left),
+      testRelation.subquery('right),
+      testRelation.where(IsNotNull(Coalesce(Seq('a, 'b)))).subquery('left),
+      testRelation.where(IsNotNull('c)).subquery('right),
+      Inner,
+      Some(Coalesce(Seq("left.a".attr, "left.b".attr)) === "right.c".attr))
+  }
+
+  test("Should not infer IsNotNull for non null-intolerant child from same 
table") {
+    comparePlans(Optimize.execute(testRelation.where(Coalesce(Seq('a, 'b)) === 
'c).analyze),
+      testRelation.where(Coalesce(Seq('a, 'b)) === 'c && 
IsNotNull('c)).analyze)

Review comment:
       ```
   hive> EXPLAIN SELECT t1.* FROM t1 WHERE coalesce(t1.a, t1.b)=t1.c;
   OK
   STAGE DEPENDENCIES:
     Stage-0 is a root stage
   
   STAGE PLANS:
     Stage: Stage-0
       Fetch Operator
         limit: -1
         Processor Tree:
           TableScan
             alias: t1
             Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column 
stats: NONE
             Filter Operator
               predicate: (COALESCE(a,b) = c) (type: boolean)
               Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column 
stats: NONE
               Select Operator
                 expressions: a (type: string), b (type: string), c (type: 
string)
                 outputColumnNames: _col0, _col1, _col2
                 Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL 
Column stats: NONE
                 ListSink
   
   Time taken: 4.026 seconds, Fetched: 20 row(s)
   ```




----------------------------------------------------------------
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]



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

Reply via email to