-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-28133][SQL] Add acosh/asinh/atanh functions to SQL #25041
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 8 commits
605df14
657c053
2580f50
89d708e
a761f1f
febdbef
0e72b3d
a495dde
6ed993a
b0af5c7
18dcf6d
bd4e7ff
10c30b0
b2db2f5
cd97401
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 |
|---|---|---|
|
|
@@ -287,6 +287,30 @@ case class Cos(child: Expression) extends UnaryMathExpression(math.cos, "COS") | |
| """) | ||
| case class Cosh(child: Expression) extends UnaryMathExpression(math.cosh, "COSH") | ||
|
|
||
| @ExpressionDescription( | ||
| usage = """ | ||
| _FUNC_(expr) - Returns inverse hyperbolic cosine of `expr`. | ||
| """, | ||
| arguments = """ | ||
| Arguments: | ||
| * expr - hyperbolic angle | ||
| """, | ||
| examples = """ | ||
| Examples: | ||
| > SELECT _FUNC_(1); | ||
| 0.0 | ||
| > SELECT _FUNC_(0); | ||
| NaN | ||
| """, | ||
| since = "3.0.0") | ||
| case class Acosh(child: Expression) | ||
| extends UnaryMathExpression((x: Double) => math.log(x + math.sqrt(x * x - 1.0)), "ACOSH") { | ||
| override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = { | ||
| defineCodeGen(ctx, ev, c => | ||
| s"${ev.value} = java.lang.Math.log($c + java.lang.Math.sqrt($c * $c - 1.0));") | ||
dongjoon-hyun marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Convert a num from one base to another | ||
| * | ||
|
|
@@ -557,6 +581,28 @@ case class Sin(child: Expression) extends UnaryMathExpression(math.sin, "SIN") | |
| """) | ||
| case class Sinh(child: Expression) extends UnaryMathExpression(math.sinh, "SINH") | ||
|
|
||
| @ExpressionDescription( | ||
| usage = """ | ||
| _FUNC_(expr) - Returns inverse hyperbolic sine of `expr`. | ||
| """, | ||
| arguments = """ | ||
| Arguments: | ||
| * expr - hyperbolic angle | ||
| """, | ||
| examples = """ | ||
| Examples: | ||
| > SELECT _FUNC_(0); | ||
| 0.0 | ||
dongjoon-hyun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """, | ||
| since = "3.0.0") | ||
| case class Asinh(child: Expression) | ||
| extends UnaryMathExpression((x: Double) => math.log(x + math.sqrt(x * x + 1.0)), "ASINH") { | ||
| override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = { | ||
| defineCodeGen(ctx, ev, c => | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as I mentioned earlier, I would prefer rewriting this as an
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also agreed to that. Could you give us the pointer to that PR(or some example)? Actually, I tried to reproduce that kind of issue within the scope of this PR. Until now, I didn't succeed. Maybe, we had better a test case for that to make it sure.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The PR was this one: #24636. The bug opened there for janino cannot happen here, but I remember I also had issues in that PR in a case when there was a cast added to the terms.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, @mgaido91 ! |
||
| s"${ev.value} = java.lang.Math.log($c + java.lang.Math.sqrt($c * $c + 1.0));") | ||
| } | ||
| } | ||
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the square root of `expr`.", | ||
| examples = """ | ||
|
|
@@ -617,6 +663,30 @@ case class Cot(child: Expression) | |
| """) | ||
| case class Tanh(child: Expression) extends UnaryMathExpression(math.tanh, "TANH") | ||
|
|
||
| @ExpressionDescription( | ||
| usage = """ | ||
| _FUNC_(expr) - Returns inverse hyperbolic tangent of `expr`. | ||
| """, | ||
| arguments = """ | ||
| Arguments: | ||
| * expr - hyperbolic angle | ||
| """, | ||
| examples = """ | ||
| Examples: | ||
| > SELECT _FUNC_(0); | ||
| 0.0 | ||
| > SELECT _FUNC_(2); | ||
| NaN | ||
dongjoon-hyun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """, | ||
| since = "3.0.0") | ||
| case class Atanh(child: Expression) | ||
| extends UnaryMathExpression((x: Double) => 0.5 * math.log((1.0 + x) / (1.0 - x)), "ATANH") { | ||
| override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = { | ||
| defineCodeGen(ctx, ev, c => | ||
| s"${ev.value} = 0.5 * java.lang.Math.log((1.0 + $c)/(1.0 - $c));") | ||
dongjoon-hyun marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Converts radians to degrees.", | ||
| arguments = """ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.