pyspark.sql.functions.hypot#

pyspark.sql.functions.hypot(col1, col2)[source]#

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

New in version 1.4.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
col1Column, column name or float

a leg.

col2Column, column name or float

b leg.

Returns
Column

length of the hypotenuse.

Examples

>>> from pyspark.sql import functions as sf
>>> spark.range(1).select(sf.hypot(sf.lit(1), sf.lit(2))).show()
+----------------+
|     HYPOT(1, 2)|
+----------------+
|2.23606797749...|
+----------------+