---
title: try_add
description: "try\\_add function in PySpark: Returns the sum of left and right and the result is null on overflow. The acceptable input types are the same as the + operator."
canonical_url: https://docs.databricks.com/aws/en/pyspark/reference/functions/try_add
---

# try\_add

Returns the sum of `left`and `right` and the result is null on overflow. The acceptable input types are the same with the `+` operator. Supports Spark Connect.

For the corresponding Databricks SQL function, see [`try_add` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/try_add.md).

## Syntax

```python
from pyspark.sql import functions as dbf

dbf.try_add(left=<left>, right=<right>)
```

## Parameters

| Parameter | Type                                | Description          |
| --------- | ----------------------------------- | -------------------- |
| `left`    | `pyspark.sql.Column or column name` | The left side value  |
| `right`   | `pyspark.sql.Column or column name` | The right side value |

## Examples

```python
from pyspark.sql import functions as dbf
spark.createDataFrame(
    [(1982, 15), (1990, 2)], ["birth", "age"]
).select("*", dbf.try_add("birth", "age")).show()
```

```Output
+-----+---+-------------------+
|birth|age|try_add(birth, age)|
+-----+---+-------------------+
| 1982| 15|               1997|
| 1990|  2|               1992|
+-----+---+-------------------+

```

```python
from pyspark.sql import functions as dbf
spark.sql("SELECT * FROM VALUES (DATE('2015-09-30')) AS TAB(date)").select("*", dbf.try_add("date", dbf.lit(1))).show()
```

```Output
+----------+----------------+
|      date|try_add(date, 1)|
+----------+----------------+
|2015-09-30|      2015-10-01|
+----------+----------------+

```
