dtenedor opened a new pull request, #47851: URL: https://github.com/apache/spark/pull/47851
### What changes were proposed in this pull request? In https://github.com/apache/spark/pull/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: ``` test("nullifzero function") { val df = Seq((0)).toDF("a") checkAnswer(df.selectExpr("nullifzero(0)"), Seq(Row(null))) checkAnswer(df.select(nullifzero(lit(0))), Seq(Row(null))) checkAnswer(df.selectExpr("nullifzero(a)"), Seq(Row(null))) checkAnswer(df.select(nullifzero(lit(5))), Seq(Row(5))) } test("zeroifnull function") { val df = Seq[(Integer)]((null)).toDF("a") checkAnswer(df.selectExpr("zeroifnull(null)"), Seq(Row(0))) checkAnswer(df.select(nullifzero(lit(null))), Seq(Row(0))) checkAnswer(df.selectExpr("zeroifnull(a)"), Seq(Row(0))) checkAnswer(df.select(zeroifnull(lit(5))), Seq(Row(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. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
