Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions python/pyspark/sql/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,23 @@ def cosh(col):
return _invoke_function_over_column("cosh", col)


def cot(col):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually you should also add them in functions.R too. ref: aeb45df

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I forgot about that. I'm pushing the follow-up PR soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine. usually SparkR one is done separately in a separate JIRA.

"""
.. versionadded:: 3.3.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):
"""
Expand Down
1 change: 1 addition & 0 deletions python/pyspark/sql/functions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
9 changes: 9 additions & 0 deletions sql/core/src/main/scala/org/apache/spark/sql/functions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1800,6 +1800,15 @@ 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.3.0
*/
def cot(e: Column): Column = withExpr { Cot(e.expr) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's only add this one (Column only).

Copy link
Contributor Author

@yutoacts yutoacts Sep 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. I saw other trig functions accept both Column and String(columnName). Should we not use columnName for the parameter?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, read the guides on the top of f functions.scala

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, thank you I just removed it.


/**
* Computes the exponential of the given value.
*
Expand Down