You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Reynold Xin (JIRA)" <ji...@apache.org> on 2016/04/03 02:49:25 UTC
[jira] [Resolved] (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 ]
Reynold Xin resolved SPARK-14338.
---------------------------------
Resolution: Fixed
Assignee: Dongjoon Hyun
Fix Version/s: 2.0.0
> 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
> Assignee: Dongjoon Hyun
> Fix For: 2.0.0
>
>
> 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[]
> scala> sql("select case when cast(null as boolean) then 1 else 2 end").explain()
> == Physical Plan ==
> WholeStageCodegen
> : +- Project [CASE WHEN null THEN 1 ELSE 2 END AS CASE WHEN CAST(NULL AS BOOLEAN) THEN 1 ELSE 2 END#14]
> : +- 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[]
> scala> sql("select case when cast(null as boolean) then 1 else 2 end").explain()
> == Physical Plan ==
> WholeStageCodegen
> : +- Project [2 AS CASE WHEN CAST(NULL AS BOOLEAN) THEN 1 ELSE 2 END#4]
> : +- INPUT
> +- Scan OneRowRelation[]
> {code}
> *Hive*
> {code}
> hive> select if(null,1,2);
> OK
> 2
> hive> select case when cast(null as boolean) then 1 else 2 end;
> OK
> 2
> {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