Skip to main content

sqrt

Computes the square root of the specified float value. Supports Spark Connect.

For the corresponding Databricks SQL function, see sqrt function.

Syntax

Python
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

Python
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()
Output
+-----+-----------+
|value|SQRT(value)|
+-----+-----------+
| -1| NaN|
| 0| 0.0|
| 1| 1.0|
| 4| 2.0|
| NULL| NULL|
+-----+-----------+