tente_multiplicar
Retorna left_right e o resultado é nulo em caso de estouro. Os tipos de entrada aceitáveis são os mesmos que os do operador _ . Compatível com Spark Connect.
Para a função Databricks SQL correspondente, consulte a funçãotry_multiply.
Sintaxe
Python
from pyspark.databricks.sql import functions as dbf
dbf.try_multiply(left=<left>, right=<right>)
Parâmetros
Parâmetro | Tipo | Descrição |
|---|---|---|
|
| multiplicando |
|
| multiplicador |
Exemplos
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|
+----------------+---+----------------------+