Skip to content

[SPARK-52345][SQL] Fix NULL behavior in scripting conditions #51047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

davidm-db
Copy link
Contributor

What changes were proposed in this pull request?

NULL is a valid Boolean "value" in SQL. Scripting engine is not properly handling cases when conditions (in if-else, case, while, repeat statements) returned NULL.

Scripting engine throws an exception in such cases, stating that the NULL is an invalid value.
Scripting engine should consider such NULLs as a False Boolean value.

Why are the changes needed?

Fixes the wrong behavior in condition evaluation for scripting statements.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Old and new unit tests.

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

No.

@github-actions github-actions bot added the SQL label May 29, 2025
@davidm-db
Copy link
Contributor Author

cc @cloud-fan @dejankrak-db @miland-db @dusantism-db please review

@cloud-fan
Copy link
Contributor

thanks, merging to master/4.0!

@cloud-fan cloud-fan closed this in 2367f58 May 29, 2025
cloud-fan pushed a commit that referenced this pull request May 29, 2025
### What changes were proposed in this pull request?

`NULL` is a valid Boolean "value" in SQL. Scripting engine is not properly handling cases when conditions (in if-else, case, while, repeat statements) returned NULL.

Scripting engine throws an exception in such cases, stating that the NULL is an invalid value.
Scripting engine should consider such NULLs as a False Boolean value.

### Why are the changes needed?

Fixes the wrong behavior in condition evaluation for scripting statements.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Old and new unit tests.

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

No.

Closes #51047 from davidm-db/scripting_conditions_null_fix.

Authored-by: David Milicevic <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
(cherry picked from commit 2367f58)
Signed-off-by: Wenchen Fan <[email protected]>
yhuang-db pushed a commit to yhuang-db/spark that referenced this pull request Jun 9, 2025
### What changes were proposed in this pull request?

`NULL` is a valid Boolean "value" in SQL. Scripting engine is not properly handling cases when conditions (in if-else, case, while, repeat statements) returned NULL.

Scripting engine throws an exception in such cases, stating that the NULL is an invalid value.
Scripting engine should consider such NULLs as a False Boolean value.

### Why are the changes needed?

Fixes the wrong behavior in condition evaluation for scripting statements.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Old and new unit tests.

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

No.

Closes apache#51047 from davidm-db/scripting_conditions_null_fix.

Authored-by: David Milicevic <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants