Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Returns the sum of leftand 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.
Syntax
from pyspark.databricks.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
from pyspark.databricks.sql import functions as dbf
spark.createDataFrame(
[(1982, 15), (1990, 2)], ["birth", "age"]
).select("*", dbf.try_add("birth", "age")).show()
+-----+---+-------------------+
|birth|age|try_add(birth, age)|
+-----+---+-------------------+
| 1982| 15| 1997|
| 1990| 2| 1992|
+-----+---+-------------------+
from pyspark.databricks.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()
+----------+----------------+
| date|try_add(date, 1)|
+----------+----------------+
|2015-09-30| 2015-10-01|
+----------+----------------+