pyspark.sql.functions.hypot

pyspark.sql.functions.hypot(col1: Union[ColumnOrName, float], col2: Union[ColumnOrName, float]) → pyspark.sql.column.Column[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
col1str, Column or float

a leg.

col2str, Column or float

b leg.

Returns
Column

length of the hypotenuse.

Examples

>>> df = spark.range(1)
>>> df.select(hypot(lit(1), lit(2))).first()
Row(HYPOT(1, 2)=2.23606...)