zhengruifeng opened a new pull request, #45796:
URL: https://github.com/apache/spark/pull/45796

   ### What changes were proposed in this pull request?
   Add `try_cast` function in DataFrame APIs
   
   ### Why are the changes needed?
   for functionality parity
   
   
   
   
   ### Does this PR introduce _any_ user-facing change?
   yes
   
   ```
       >>> from pyspark.sql import functions as sf
       >>> from pyspark.sql.types import LongType
       >>> df = spark.createDataFrame(
       ...      [(2, "123"), (5, "Bob"), (3, None)], ["age", "name"])
       >>> df.select(sf.try_cast("name", LongType())).show()
       +----+
       |name|
       +----+
       | 123|
       |NULL|
       |NULL|
       +----+
   
   ```
   
   ### How was this patch tested?
   new tests
   
   ### 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]

Reply via email to