[
https://issues.apache.org/jira/browse/SPARK-14502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dongjoon Hyun updated SPARK-14502:
----------------------------------
Description:
We can simplifies binary comparisons with semantically-equal operands:
1) Replace '<=>' with 'true' literal.
2) Replace '=', '<=', and '>=' with 'true' literal if both operands are
non-nullable.
3) Replace '<' and '>' with 'false' literal if both operands are non-nullable.
For example, the following example plan
{code}
scala> sql("SELECT * FROM (SELECT explode(array(1,2,3)) a) T WHERE a BETWEEN a
AND a+7").explain()
...
: +- Filter ((a#59 >= a#59) && (a#59 <= (a#59 + 7)))
...
{code}
will be optimized into the following.
{code}
: +- Filter (a#47 <= (a#47 + 7))
{code}
was:
For non-nullable binary comparisons, we can simplifies `semantically-equal
expressions` further:
1) Replace '=', '<=', and '>=' with 'true' literal
2) Replace '<' and '>' with 'false' literal
For example, the following example plan
{code}
scala> sql("SELECT * FROM (SELECT explode(array(1,2,3)) a) T WHERE a BETWEEN a
AND a+7").explain()
...
: +- Filter ((a#59 >= a#59) && (a#59 <= (a#59 + 7)))
...
{code}
will be optimized into the following.
{code}
: +- Filter (a#47 <= (a#47 + 7))
{code}
> Add optimization for Binary Comparison Simplification
> -----------------------------------------------------
>
> Key: SPARK-14502
> URL: https://issues.apache.org/jira/browse/SPARK-14502
> Project: Spark
> Issue Type: Improvement
> Components: SQL
> Reporter: Dongjoon Hyun
>
> We can simplifies binary comparisons with semantically-equal operands:
> 1) Replace '<=>' with 'true' literal.
> 2) Replace '=', '<=', and '>=' with 'true' literal if both operands are
> non-nullable.
> 3) Replace '<' and '>' with 'false' literal if both operands are non-nullable.
> For example, the following example plan
> {code}
> scala> sql("SELECT * FROM (SELECT explode(array(1,2,3)) a) T WHERE a BETWEEN
> a AND a+7").explain()
> ...
> : +- Filter ((a#59 >= a#59) && (a#59 <= (a#59 + 7)))
> ...
> {code}
> will be optimized into the following.
> {code}
> : +- Filter (a#47 <= (a#47 + 7))
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]