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 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_multiply function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.try_multiply(left=<left>, right=<right>)
Parameters
| Parameter | Type | Description |
|---|---|---|
left |
pyspark.sql.Column or column name |
multiplicand |
right |
pyspark.sql.Column or column name |
multiplier |
Examples
from pyspark.databricks.sql import functions as dbf
spark.createDataFrame(
[(6000, 15), (1990, 2)], ["a", "b"]
).select("*", dbf.try_multiply("a", "b")).show()
+----+---+------------------+
| a| b|try_multiply(a, b)|
+----+---+------------------+
|6000| 15| 90000|
|1990| 2| 3980|
+----+---+------------------+
from pyspark.databricks.sql import functions as dbf
df = spark.range(6).select(dbf.make_interval(dbf.col("id"), dbf.lit(3)).alias("itvl"), "id")
df.select("*", dbf.try_multiply("itvl", "id")).show()
+----------------+---+----------------------+
| itvl| id|try_multiply(itvl, id)|
+----------------+---+----------------------+
| 3 months| 0| 0 seconds|
|1 years 3 months| 1| 1 years 3 months|
|2 years 3 months| 2| 4 years 6 months|
|3 years 3 months| 3| 9 years 9 months|
|4 years 3 months| 4| 17 years|
|5 years 3 months| 5| 26 years 3 months|
+----------------+---+----------------------+