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

Wenchen Fan reassigned SPARK-28477:
-----------------------------------

    Assignee: David Vrba

> 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
>            Assignee: David Vrba
>            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-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to