-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-20751][SQL] Add built-in SQL Function - COT #17999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1990,6 +1990,14 @@ object functions { | |
| */ | ||
| def tan(columnName: String): Column = tan(Column(columnName)) | ||
|
|
||
| /** | ||
| * Computes the cotangent of the given column. | ||
| * | ||
| * @group math_funcs | ||
| * @since 2.3.0 | ||
| */ | ||
| def cot(e: Column): Column = withExpr { Cot(e.expr) } | ||
|
||
|
|
||
| /** | ||
| * Computes the hyperbolic tangent of the given value. | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ select 1 - 2; | |
| select 2 * 5; | ||
| select 5 % 3; | ||
| select pmod(-7, 3); | ||
| select cot(1); | ||
|
||
|
|
||
| -- check operator precedence. | ||
| -- We follow Oracle operator precedence in the table below that lists the levels of precedence | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -274,6 +274,13 @@ class MathFunctionsSuite extends QueryTest with SharedSQLContext { | |
| Row(1, -1)) | ||
| } | ||
|
|
||
| test("cot") { | ||
| testOneToOneMathFunction(cot, (d: Double) => 1 / math.tan(d)) | ||
| checkAnswer( | ||
| sql(s"SELECT cot(null), cot(0), cot(-1), cot(${Double.MaxValue})"), | ||
|
||
| Row(null, Double.PositiveInfinity, -0.6420926159343306, -201.53099572900314)) | ||
| } | ||
|
|
||
| test("pow / power") { | ||
| testTwoToOneMathFunction(pow, pow, math.pow) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it fits one line, could you change it to?