You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "ulysses you (Jira)" <ji...@apache.org> on 2019/12/25 13:54:00 UTC

[jira] [Updated] (SPARK-30353) Use constraints in SimplifyBinaryComparison optimization

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

ulysses you updated SPARK-30353:
--------------------------------
    Description: 
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
    +- Relation[c1#20]
```

  was:
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. Besides 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
    +- Relation[c1#20]
```


> 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
>            Priority: Minor
>
> 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
>     +- Relation[c1#20]
> ```



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

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