GitHub user dongjoon-hyun opened a pull request:
https://github.com/apache/spark/pull/18257
[SPARK-21044][SPARK-21041][SQL] Add RemoveInvalidRange optimizer
## What changes were proposed in this pull request?
This PR aims to add an optimizer remove invalid `Range` operators from the
beginning. There are two cases of invalidity.
1. The `start` and `end` values are equal.
2. The sign of `step` does not match `start` and `end`'s increasing order.
With `wholeStageCodeGen` option, both cases generates unnecessary java
codes. More worse,
[SPARK-21041](https://issues.apache.org/jira/browse/SPARK-21041) reports that
the second case returns wrong result.
**BEFORE**
```
scala> spark.range(0,0,1).explain
== Physical Plan ==
*Range (0, 0, step=1, splits=8)
```
**AFTER**
```
scala> spark.range(0,0,1).explain
== Physical Plan ==
LocalTableScan <empty>, [id#0L]
```
## How was this patch tested?
Pass the Jenkins with newly added test cases.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/dongjoon-hyun/spark SPARK-21041
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/18257.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #18257
----
commit 6ab9b6fb559ab11ac95078a1672672edf85efbac
Author: Dongjoon Hyun <[email protected]>
Date: 2017-06-10T01:45:23Z
[SPARK-21044][SPARK-21041][SQL] Add RemoveInvalidRange optimizer
**BEFORE**
```
scala> spark.range(0,0,1).explain
== Physical Plan ==
*Range (0, 0, step=1, splits=8)
```
**AFTER**
```
scala> spark.range(0,0,1).explain
== Physical Plan ==
LocalTableScan <empty>, [id#0L]
```
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]