Skip to main content

hypot

Computes sqrt(a^2 + b^2) without intermediate overflow or underflow. Supports Spark Connect.

For the corresponding Databricks SQL function, see hypot function.

Syntax

Python
from pyspark.databricks.sql import functions as dbf

dbf.hypot(col1=<col1>, col2=<col2>)

Parameters

Parameter

Type

Description

col1

pyspark.sql.Column, column name or float

a leg.

col2

pyspark.sql.Column, column name or float

b leg.

Returns

pyspark.sql.Column: length of the hypotenuse.

Examples

Python
from pyspark.databricks.sql import functions as dbf
spark.range(1).select(dbf.hypot(dbf.lit(1), dbf.lit(2))).show()
Output
+----------------+
| HYPOT(1, 2)|
+----------------+
|2.23606797749...|
+----------------+