wangyum opened a new pull request #28642:
URL: https://github.com/apache/spark/pull/28642


   ### What changes were proposed in this pull request?
   
   We should infer `IsNotNull` for all children of `NullIntolerant` 
expressions. For example:
   ```sql
   CREATE TABLE t1(c1 string, c2 string);
   CREATE TABLE t2(c1 string, c2 string);
   EXPLAIN SELECT t1.* FROM t1 JOIN t2 ON coalesce(t1.c1, t1.c2)=t2.c1;
   ```
   After this pr the query plan is:
   ```
   == Physical Plan ==
   *(5) Project [c1#23, c2#24]
   +- *(5) SortMergeJoin [coalesce(c1#23, c2#24)], [c1#25], Inner
      :- *(2) Sort [coalesce(c1#23, c2#24) ASC NULLS FIRST], false, 0
      :  +- Exchange hashpartitioning(coalesce(c1#23, c2#24), 200), true, 
[id=#95]
      :     +- *(1) Filter isnotnull(coalesce(c1#23, c2#24))
      :        +- Scan hive default.t1 [c1#23, c2#24], HiveTableRelation 
`default`.`t1`, org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, [c1#23, 
c2#24], Statistics(sizeInBytes=8.0 EiB)
      +- *(4) Sort [c1#25 ASC NULLS FIRST], false, 0
         +- Exchange hashpartitioning(c1#25, 200), true, [id=#103]
            +- *(3) Filter isnotnull(c1#25)
               +- Scan hive default.t2 [c1#25], HiveTableRelation 
`default`.`t2`, org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, [c1#25, 
c2#26], Statistics(sizeInBytes=8.0 EiB)
   ```
   
   ### Why are the changes needed?
   
   Improve query performance and Hive support this optimization.
   
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Unit test and benchmark test.
   Before this pr:
   
![image](https://issues.apache.org/jira/secure/attachment/13003914/13003914_default.png)
   
   After this pr:
   
![image](https://issues.apache.org/jira/secure/attachment/13003913/13003913_infer.png)
   


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