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

[jira] [Resolved] (SPARK-28477) Rewrite `CASE WHEN cond THEN ifTrue OTHERWISE ifFalse` END into `IF(cond, ifTrue, ifFalse)`

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

Wenchen Fan resolved SPARK-28477.
---------------------------------
    Fix Version/s: 3.0.0
       Resolution: Fixed

Issue resolved by pull request 26294
[https://github.com/apache/spark/pull/26294]

> Rewrite `CASE WHEN cond THEN ifTrue OTHERWISE ifFalse` END into `IF(cond, ifTrue, ifFalse)`
> -------------------------------------------------------------------------------------------
>
>                 Key: SPARK-28477
>                 URL: https://issues.apache.org/jira/browse/SPARK-28477
>             Project: Spark
>          Issue Type: Improvement
>          Components: Optimizer, SQL
>    Affects Versions: 3.0.0
>            Reporter: Josh Rosen
>            Priority: Major
>             Fix For: 3.0.0
>
>
> Spark SQL has both {{CASE WHEN}} and {{IF}} expressions.
> I've seen many cases where end-users write
> {code:java}
> when(x, ifTrue).otherwise(ifFalse){code}
> because Spark doesn't have a {{org.apache.spark.sql.functions._}} method for the {{If}} expression.
> Unfortunately, {{CASE WHEN}} generates substantial code bloat because its codgen is implemented using a {{do-while}} loop. In some performance-critical frameworks, I've modified our code to directly construct the Catalyst {{If}} expression, but this is toilsome and confusing to end-users.
> If we have a {{CASE WHEN}} which has only two branches, like the example given above, then Spark should automatically rewrite it into a simple {{IF}} expression.



--
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