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

Richard Durkee updated SPARK-56976:
-----------------------------------
    Description: 
Currently Spark's IF function requires exactly three arguments: {{IF(condition, 
trueValue, falseValue)}}

The two-argument form, {{{}IF(condition, value){}}}, returns {{value}} when 
true and {{NULL}} when false. This syntax is supported by Trino and Presto but 
rejected by Spark with an arity error. 

Although there are existing ways to express this in Spark, such as 
{{IF(condition, value, NULL)}} or {{{}CASE WHEN condition THEN value END{}}}, 
the two-argument form is more concise and matches user expectations when 
migrating from other SQL engines. This is especially important for automated 
migration. 

 

  was:
Currently Spark's IF function requires exactly three arguments: {{IF(condition, 
trueValue, falseValue)}}

The two-argument form, {{{}IF(condition, value){}}}, returns {{value}} when 
true and {{NULL}} when false. This is supported by Trino and Presto but 
rejected by Spark with an arity error. 

Although there are existing ways to express this in Spark, such as 
{{IF(condition, value, NULL)}} or {{{}CASE WHEN condition THEN value END{}}}, 
the two-argument form is more concise and matches user expectations when 
migrating from other SQL engines. This is especially important for automated 
migration. 

 


> Support Two-Argument IF(condition, value) Returning NULL
> --------------------------------------------------------
>
>                 Key: SPARK-56976
>                 URL: https://issues.apache.org/jira/browse/SPARK-56976
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 5.0.0
>            Reporter: Richard Durkee
>            Priority: Minor
>              Labels: pull-request-available
>
> Currently Spark's IF function requires exactly three arguments: 
> {{IF(condition, trueValue, falseValue)}}
> The two-argument form, {{{}IF(condition, value){}}}, returns {{value}} when 
> true and {{NULL}} when false. This syntax is supported by Trino and Presto 
> but rejected by Spark with an arity error. 
> Although there are existing ways to express this in Spark, such as 
> {{IF(condition, value, NULL)}} or {{{}CASE WHEN condition THEN value END{}}}, 
> the two-argument form is more concise and matches user expectations when 
> migrating from other SQL engines. This is especially important for automated 
> migration. 
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to