-
Notifications
You must be signed in to change notification settings - Fork 28.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-49306][PYTHON][SQL] Create SQL function aliases for 'zeroifnul…
…l' and 'nullifzero' ### What changes were proposed in this pull request? In #47817 we added new SQL functions `zeroifnull` and `nullifzero`. In this PR we add Scala and Python DataFrame API endpoints for them. For example, in Scala: ``` var df = Seq((0)).toDF("a") df.selectExpr("nullifzero(0)").collect() > null df.select(nullifzero(lit(0))).collect() > null df.selectExpr("nullifzero(a)").collect() > null df.select(nullifzero(lit(5))).collect() > 5 df = Seq[(Integer)]((null)).toDF("a") df.selectExpr("zeroifnull(null)").collect() > 5 df.select(nullifzero(lit(null))).collect() > 0 df.selectExpr("zeroifnull(a)").collect() > 0 df.select(zeroifnull(lit(5))) > 5 ``` ### Why are the changes needed? This improves DataFrame parity with the SQL API. ### Does this PR introduce _any_ user-facing change? Yes, see above. ### How was this patch tested? This PR adds unit test coverage. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #47851 from dtenedor/dataframe-zeroifnull. Authored-by: Daniel Tenedorio <[email protected]> Signed-off-by: Max Gekk <[email protected]>
- Loading branch information
Showing
7 changed files
with
218 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,9 +48,11 @@ Conditional Functions | |
ifnull | ||
nanvl | ||
nullif | ||
nullifzero | ||
nvl | ||
nvl2 | ||
when | ||
zeroifnull | ||
|
||
|
||
Predicate Functions | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters