Skip to content

[SPARK-56976][SQL] Support Two-Argument IF(condition, value) Returning NULL#56025

Open
Richard-Durkee wants to merge 1 commit into
apache:masterfrom
Richard-Durkee:two-arg-if
Open

[SPARK-56976][SQL] Support Two-Argument IF(condition, value) Returning NULL#56025
Richard-Durkee wants to merge 1 commit into
apache:masterfrom
Richard-Durkee:two-arg-if

Conversation

@Richard-Durkee
Copy link
Copy Markdown

What changes were proposed in this pull request?

Add an auxiliary constructor to the If expression that accepts two arguments, defaulting falseValue to Literal(null). This allows IF(condition, value) to return NULL when the condition is false.

Why are the changes needed?

The two-argument IF expression is supported by MySQL, Trino/Presto, and BigQuery. Users migrating queries from these systems currently get an arity error.

Does this PR introduce any user-facing change?

Yes. IF(condition, value) now returns value when true and NULL when false, instead of throwing an error.

How was this patch tested?

New golden file SQL test (if-two-arg.sql). Existing conditional-functions.sql and ifCoercion.sql tests pass with no regressions.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant