[ 
https://issues.apache.org/jira/browse/SPARK-30353?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Wenchen Fan resolved SPARK-30353.
---------------------------------
    Fix Version/s: 3.0.0
       Resolution: Fixed

Issue resolved by pull request 27008
[https://github.com/apache/spark/pull/27008]

> Use constraints in SimplifyBinaryComparison optimization
> --------------------------------------------------------
>
>                 Key: SPARK-30353
>                 URL: https://issues.apache.org/jira/browse/SPARK-30353
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 3.0.0
>            Reporter: ulysses you
>            Assignee: ulysses you
>            Priority: Minor
>             Fix For: 3.0.0
>
>
> Now Spark can propagate constraint during sql optimization when 
> `spark.sql.constraintPropagation.enabled` is true, then `where c = 1` will 
> convert to `where c = 1 and c is not null`. We also can use constraint in 
> `SimplifyBinaryComparison`.
> `SimplifyBinaryComparison` will simplify expression which is not nullable and 
> semanticEquals. And we also can simplify if one expression is infered 
> `IsNotNull`.
> For e.g.
> ```
> create table test (c1 string);
> explain extended select c1 from test where c1 = c1 limit 10;
> -- before
> GlobalLimit 10
> +- LocalLimit 10
>    +- Filter (isnotnull(c1#20) AND (c1#20 = c1#20))
>       +- Relation[c1#20]
> -- after
> GlobalLimit 10
> +- LocalLimit 10
>     +- Filter (isnotnull(c1#20)
>         +- Relation[c1#20]
> explain extended select c1 from test where c1 > c1 limit 10;
> -- before
> GlobalLimit 10
> +- LocalLimit 10
>    +- Filter (isnotnull(c1#20) && (c1#20 > c1#20))
>       +- Relation[c1#20]
> -- after
> LocalRelation <empty>, [c1#20]
> ```



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to