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 left-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_subtract function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.try_subtract(left=<left>, right=<right>)
Parameters
| Parameter | Type | Description |
|---|---|---|
left |
pyspark.sql.Column or column name |
|
right |
pyspark.sql.Column or column name |
Examples
from pyspark.databricks.sql import functions as dbf
spark.createDataFrame(
[(1982, 15), (1990, 2)], ["birth", "age"]
).select("*", dbf.try_subtract("birth", "age")).show()
+-----+---+------------------------+
|birth|age|try_subtract(birth, age)|
+-----+---+------------------------+
| 1982| 15| 1967|
| 1990| 2| 1988|
+-----+---+------------------------+
from pyspark.databricks.sql import functions as dbf
spark.sql(
"SELECT * FROM VALUES (DATE('2015-10-01')) AS TAB(date)"
).select("*", dbf.try_subtract("date", dbf.lit(1))).show()
+----------+---------------------+
| date|try_subtract(date, 1)|
+----------+---------------------+
|2015-10-01| 2015-09-30|
+----------+---------------------+