หมายเหตุ
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลอง ลงชื่อเข้าใช้หรือเปลี่ยนไดเรกทอรีได้
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลองเปลี่ยนไดเรกทอรีได้
Computes the square root of the specified float value. Supports Spark Connect.
For the corresponding Databricks SQL function, see sqrt function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.sqrt(col=<col>)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or column name |
target column to compute on. |
Returns
pyspark.sql.Column: column for computed results.
Examples
from pyspark.databricks.sql import functions as dbf
spark.sql(
"SELECT * FROM VALUES (-1), (0), (1), (4), (NULL) AS TAB(value)"
).select("*", dbf.sqrt("value")).show()
+-----+-----------+
|value|SQRT(value)|
+-----+-----------+
| -1| NaN|
| 0| 0.0|
| 1| 1.0|
| 4| 2.0|
| NULL| NULL|
+-----+-----------+