[SPARK-56976][SQL] Support Two-Argument IF(condition, value) Returning NULL#56025
[SPARK-56976][SQL] Support Two-Argument IF(condition, value) Returning NULL#56025Richard-Durkee wants to merge 1 commit into
Conversation
|
Hi @Richard-Durkee, thanks for adding this compatibility feature! The change is clean and well-tested. I noticed this aligns with MySQL/Trino/BigQuery behavior. A couple of thoughts:
Minor: Have you considered adding a note to the SQL function documentation about this two-argument form? Let me know if I can help with anything! |
Thanks! The |
What changes were proposed in this pull request?
Add an auxiliary constructor to the
Ifexpression that accepts two arguments, defaultingfalseValuetoLiteral(null). This allowsIF(condition, value)to return NULL when the condition is false.Why are the changes needed?
The two-argument IF expression is supported by Trino and Presto. Users migrating queries from these systems currently get an arity error.
Does this PR introduce any user-facing change?
Yes.
IF(condition, value)now returnsvaluewhen true and NULL when false, instead of throwing an error.How was this patch tested?
New golden file SQL test (
if-two-arg.sql). Existingconditional-functions.sqlandifCoercion.sqltests pass with no regressions.Was this patch authored or co-authored using generative AI tooling?
No