sin
Computes sine of the input column. Supports Spark Connect.
For the corresponding Databricks SQL function, see sin function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.sin(col=<col>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| target column to compute on. |
Returns
pyspark.sql.Column: sine of the angle, as if computed by java.lang.Math.sin()
Examples
Python
from pyspark.databricks.sql import functions as dbf
spark.sql(
"SELECT * FROM VALUES (0.0), (PI() / 2), (PI() / 4) AS TAB(value)"
).select("*", dbf.sin("value")).show()
Output
+------------------+------------------+
| value| SIN(value)|
+------------------+------------------+
| 0.0| 0.0|
|1.5707963267948...| 1.0|
|0.7853981633974...|0.7071067811865...|
+------------------+------------------+
Python
from pyspark.databricks.sql import functions as dbf
spark.sql(
"SELECT * FROM VALUES (FLOAT('NAN')), (NULL) AS TAB(value)"
).select("*", dbf.sin("value")).show()
Output
+-----+----------+
|value|SIN(value)|
+-----+----------+
| NaN| NaN|
| NULL| NULL|
+-----+----------+