Piezīmes
Lai piekļūtu šai lapai, ir nepieciešama autorizācija. Varat mēģināt pierakstīties vai mainīt direktorijus.
Lai piekļūtu šai lapai, ir nepieciešama autorizācija. Varat mēģināt mainīt direktorijus.
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|
+----------+----------------+