try_multiply
left _ rightを返し、オーバーフローの場合は結果は null になります。許容される入力タイプは_演算子と同じです。Spark Connect をサポートします。
対応する Databricks SQL 関数については、 try_multiply関数を参照してください。
構文
Python
from pyspark.databricks.sql import functions as dbf
dbf.try_multiply(left=<left>, right=<right>)
パラメーター
パラメーター | Type | 説明 |
|---|---|---|
|
| 被乗数 |
|
| 乗数 |
例
Python
from pyspark.databricks.sql import functions as dbf
spark.createDataFrame(
[(6000, 15), (1990, 2)], ["a", "b"]
).select("*", dbf.try_multiply("a", "b")).show()
Output
+----+---+------------------+
| a| b|try_multiply(a, b)|
+----+---+------------------+
|6000| 15| 90000|
|1990| 2| 3980|
+----+---+------------------+
Python
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()
Output
+----------------+---+----------------------+
| 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|
+----------------+---+----------------------+