From c7b7e1d8b17bdf3060c32ac0985e15d923f9680c Mon Sep 17 00:00:00 2001 From: Yuto Akutsu Date: Fri, 3 Sep 2021 13:40:39 +0900 Subject: [PATCH 1/4] add cotangent support on DataFrame --- .../scala/org/apache/spark/sql/functions.scala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala index c7be437b8c08..306a97b73ab2 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala @@ -1800,6 +1800,24 @@ object functions { */ def cosh(columnName: String): Column = cosh(Column(columnName)) + /** + * @param e angle in radians + * @return cotangent of the angle + * + * @group math_funcs + * @since 3.2.0 + */ + def cot(e: Column): Column = withExpr { Cot(e.expr) } + + /** + * @param columnName angle in radians + * @return cotangent of the angle + * + * @group math_funcs + * @since 3.2.0 + */ + def cot(columnName: String): Column = cot(Column(columnName)) + /** * Computes the exponential of the given value. * From ee170d6162125c566fca88b9628aab681378ed17 Mon Sep 17 00:00:00 2001 From: Yuto Akutsu Date: Fri, 3 Sep 2021 14:57:36 +0900 Subject: [PATCH 2/4] add cotangent support on PySpark --- python/pyspark/sql/functions.py | 17 +++++++++++++++++ python/pyspark/sql/functions.pyi | 1 + 2 files changed, 18 insertions(+) diff --git a/python/pyspark/sql/functions.py b/python/pyspark/sql/functions.py index 645244209772..194b904a3c5e 100644 --- a/python/pyspark/sql/functions.py +++ b/python/pyspark/sql/functions.py @@ -377,6 +377,23 @@ def cosh(col): return _invoke_function_over_column("cosh", col) +def cot(col): + """ + .. versionadded:: 3.2.0 + + Parameters + ---------- + col : :class:`~pyspark.sql.Column` or str + angle in radians + + Returns + ------- + :class:`~pyspark.sql.Column` + cotangent of the angle. + """ + return _invoke_function_over_column("cot", col) + + @since(1.4) def exp(col): """ diff --git a/python/pyspark/sql/functions.pyi b/python/pyspark/sql/functions.pyi index 5c39706176a9..143fa133f4fe 100644 --- a/python/pyspark/sql/functions.pyi +++ b/python/pyspark/sql/functions.pyi @@ -298,6 +298,7 @@ def collect_set(col: ColumnOrName) -> Column: ... def column(col: str) -> Column: ... def cos(col: ColumnOrName) -> Column: ... def cosh(col: ColumnOrName) -> Column: ... +def cot(col: ColumnOrName) -> Column: ... def count(col: ColumnOrName) -> Column: ... def cume_dist() -> Column: ... def degrees(col: ColumnOrName) -> Column: ... From c1425274409ff209377298b728f4ddec5b35ca1a Mon Sep 17 00:00:00 2001 From: Yuto Akutsu <87687356+yutoacts@users.noreply.github.com> Date: Fri, 3 Sep 2021 17:15:17 +0900 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Hyukjin Kwon --- python/pyspark/sql/functions.py | 6 +++--- .../src/main/scala/org/apache/spark/sql/functions.scala | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/pyspark/sql/functions.py b/python/pyspark/sql/functions.py index 194b904a3c5e..e418c0d11f8f 100644 --- a/python/pyspark/sql/functions.py +++ b/python/pyspark/sql/functions.py @@ -379,17 +379,17 @@ def cosh(col): def cot(col): """ - .. versionadded:: 3.2.0 + .. versionadded:: 3.3.0 Parameters ---------- col : :class:`~pyspark.sql.Column` or str - angle in radians + Angle in radians Returns ------- :class:`~pyspark.sql.Column` - cotangent of the angle. + Cotangent of the angle. """ return _invoke_function_over_column("cot", col) diff --git a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala index 306a97b73ab2..f92bbaf21be4 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala @@ -1805,7 +1805,7 @@ object functions { * @return cotangent of the angle * * @group math_funcs - * @since 3.2.0 + * @since 3.3.0 */ def cot(e: Column): Column = withExpr { Cot(e.expr) } From a4ec1e1f6f605f19ec3740faf0d6678bfc7b17d9 Mon Sep 17 00:00:00 2001 From: Yuto Akutsu Date: Mon, 6 Sep 2021 10:34:16 +0900 Subject: [PATCH 4/4] removed cot function with string parameter --- .../src/main/scala/org/apache/spark/sql/functions.scala | 9 --------- 1 file changed, 9 deletions(-) diff --git a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala index f92bbaf21be4..781a2dd5649e 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala @@ -1809,15 +1809,6 @@ object functions { */ def cot(e: Column): Column = withExpr { Cot(e.expr) } - /** - * @param columnName angle in radians - * @return cotangent of the angle - * - * @group math_funcs - * @since 3.2.0 - */ - def cot(columnName: String): Column = cot(Column(columnName)) - /** * Computes the exponential of the given value. *