You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Dongjoon Hyun (JIRA)" <ji...@apache.org> on 2016/04/02 04:37:25 UTC

[jira] [Updated] (SPARK-14338) Improve `SimplifyConditionals` rule to handle `null` in IF/CASEWHEN

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

Dongjoon Hyun updated SPARK-14338:
----------------------------------
    Description: 
Currently, `SimplifyConditionals` handles `true` and `false` to optimize branches. This issue improves `SimplifyConditionals` to take advantage of `null` conditions for `if` and `CaseWhen` expressions, too.

*Before*
{code}
scala> sql("SELECT IF(null, 1, 0)").explain()
== Physical Plan ==
WholeStageCodegen
:  +- Project [if (null) 1 else 0 AS (IF(CAST(NULL AS BOOLEAN), 1, 0))#4]
:     +- INPUT
+- Scan OneRowRelation[]
{code}

*After*
{code}
scala> sql("SELECT IF(null, 1, 0)").explain()
== Physical Plan ==
WholeStageCodegen
:  +- Project [0 AS (IF(CAST(NULL AS BOOLEAN), 1, 0))#4]
:     +- INPUT
+- Scan OneRowRelation[]
{code}

*Hive*
{code}
$ hive -e "select if(null,1,2)"
OK
2
Time taken: 1.652 seconds, Fetched: 1 row(s)
{code}

  was:Currently, `SimplifyConditionals` handles `true` and `false` to optimize branches. This issue improves `SimplifyConditionals` to take advantage of `null` conditions for `if` and `CaseWhen` expressions, too.


> Improve `SimplifyConditionals` rule to handle `null` in IF/CASEWHEN
> -------------------------------------------------------------------
>
>                 Key: SPARK-14338
>                 URL: https://issues.apache.org/jira/browse/SPARK-14338
>             Project: Spark
>          Issue Type: Improvement
>          Components: Optimizer, SQL
>            Reporter: Dongjoon Hyun
>
> Currently, `SimplifyConditionals` handles `true` and `false` to optimize branches. This issue improves `SimplifyConditionals` to take advantage of `null` conditions for `if` and `CaseWhen` expressions, too.
> *Before*
> {code}
> scala> sql("SELECT IF(null, 1, 0)").explain()
> == Physical Plan ==
> WholeStageCodegen
> :  +- Project [if (null) 1 else 0 AS (IF(CAST(NULL AS BOOLEAN), 1, 0))#4]
> :     +- INPUT
> +- Scan OneRowRelation[]
> {code}
> *After*
> {code}
> scala> sql("SELECT IF(null, 1, 0)").explain()
> == Physical Plan ==
> WholeStageCodegen
> :  +- Project [0 AS (IF(CAST(NULL AS BOOLEAN), 1, 0))#4]
> :     +- INPUT
> +- Scan OneRowRelation[]
> {code}
> *Hive*
> {code}
> $ hive -e "select if(null,1,2)"
> OK
> 2
> Time taken: 1.652 seconds, Fetched: 1 row(s)
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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