pyspark.sql.functions.hypot#

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

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

Added in version 1.4.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters:
col1Column, column name or float

a leg. A column that evaluates to a double.

col2Column, column name or float

b leg. A column that evaluates to a double.

Returns:
Column

length of the hypotenuse. Returns a column that evaluates to a double.

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...|
+----------------+