pyspark.sql.functions.try_sum

pyspark.sql.functions.try_sum(col: ColumnOrName) → pyspark.sql.column.Column[source]

Returns the sum calculated from values of a group and the result is null on overflow.

New in version 3.5.0.

Parameters
colColumn or str

Examples

>>> import pyspark.sql.functions as sf
>>> spark.range(10).select(sf.try_sum("id")).show()
+-----------+
|try_sum(id)|
+-----------+
|         45|
+-----------+