[GitHub] [spark] Tonix517 commented on a change in pull request #24994: [SPARK-28133] Adding inverse hyperbolic functions in SQL
Tonix517 commented on a change in pull request #24994: [SPARK-28133] Adding inverse hyperbolic functions in SQL URL: https://github.com/apache/spark/pull/24994#discussion_r299770079 ## File path: sql/core/src/main/scala/org/apache/spark/sql/functions.scala ## @@ -2023,11 +2041,29 @@ object functions { /** * @param columnName hyperbolic angle - * @return hyperbolic sine of the given value, as if computed by `java.lang.Math.sinh` + * @return inverse hyperbolic sine of the given value * * @group math_funcs - * @since 1.4.0 + * @since 3.0.0 */ + def asinh(columnName: String): Column = asinh(Column(columnName)) Review comment: thanks Hyukjin. just removed them from language APIs. now only available in SQL This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] Tonix517 commented on a change in pull request #24994: [SPARK-28133] Adding inverse hyperbolic functions in SQL
Tonix517 commented on a change in pull request #24994: [SPARK-28133] Adding inverse hyperbolic functions in SQL URL: https://github.com/apache/spark/pull/24994#discussion_r299575256 ## File path: sql/core/src/main/scala/org/apache/spark/sql/functions.scala ## @@ -2023,11 +2041,29 @@ object functions { /** * @param columnName hyperbolic angle - * @return hyperbolic sine of the given value, as if computed by `java.lang.Math.sinh` + * @return inverse hyperbolic sine of the given value * * @group math_funcs - * @since 1.4.0 + * @since 3.0.0 */ + def asinh(columnName: String): Column = asinh(Column(columnName)) Review comment: Hi @HyukjinKwon, do you mean we remove then from R for the same reason we removed them from Python, and just keep them in Scala? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] Tonix517 commented on a change in pull request #24994: [SPARK-28133] Adding inverse hyperbolic functions in SQL
Tonix517 commented on a change in pull request #24994: [SPARK-28133] Adding inverse hyperbolic functions in SQL URL: https://github.com/apache/spark/pull/24994#discussion_r298813645 ## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala ## @@ -557,6 +578,27 @@ 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 + """) +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 => + s"${ev.value} = java.lang.Math.log($c + java.lang.Math.sqrt($c * $c + 1.0));") Review comment: took a closer look at asinh\atanh implementation in FastMath. the negative handling inside is to apply calculation optimization on abs(double a) and then apply proper sign at the end of the function to return, which should produce the same value as the original formula i'm using here (https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions#Definitions_in_terms_of_logarithms). But FastMath runs faster than the original functions though. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] Tonix517 commented on a change in pull request #24994: [SPARK-28133] Adding inverse hyperbolic functions in SQL
Tonix517 commented on a change in pull request #24994: [SPARK-28133] Adding inverse hyperbolic functions in SQL URL: https://github.com/apache/spark/pull/24994#discussion_r298775993 ## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala ## @@ -557,6 +578,27 @@ 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 + """) +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 => + s"${ev.value} = java.lang.Math.log($c + java.lang.Math.sqrt($c * $c + 1.0));") Review comment: Also I just tried the code with several negative values, i got correct return values. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] Tonix517 commented on a change in pull request #24994: [SPARK-28133] Adding inverse hyperbolic functions in SQL
Tonix517 commented on a change in pull request #24994: [SPARK-28133] Adding inverse hyperbolic functions in SQL URL: https://github.com/apache/spark/pull/24994#discussion_r298770863 ## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala ## @@ -557,6 +578,27 @@ 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 + """) +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 => + s"${ev.value} = java.lang.Math.log($c + java.lang.Math.sqrt($c * $c + 1.0));") Review comment: thanks for reminding me of FastMath lib. Maybe we can simply use that lib here, without this hand-crafted calculation? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] Tonix517 commented on a change in pull request #24994: [SPARK-28133] Adding inverse hyperbolic functions in SQL
Tonix517 commented on a change in pull request #24994: [SPARK-28133] Adding inverse hyperbolic functions in SQL URL: https://github.com/apache/spark/pull/24994#discussion_r298755461 ## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala ## @@ -557,6 +578,27 @@ 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 + """) +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 => + s"${ev.value} = java.lang.Math.log($c + java.lang.Math.sqrt($c * $c + 1.0));") Review comment: It will return NaN, the same behavior as for existing sinh implementation. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] Tonix517 commented on a change in pull request #24994: [SPARK-28133] Adding inverse hyperbolic functions in SQL
Tonix517 commented on a change in pull request #24994: [SPARK-28133] Adding inverse hyperbolic functions in SQL URL: https://github.com/apache/spark/pull/24994#discussion_r298755461 ## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala ## @@ -557,6 +578,27 @@ 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 + """) +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 => + s"${ev.value} = java.lang.Math.log($c + java.lang.Math.sqrt($c * $c + 1.0));") Review comment: It will return NaN, it is the same behavior as for existing sinh implementation. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] Tonix517 commented on a change in pull request #24994: [SPARK-28133] Adding inverse hyperbolic functions in SQL
Tonix517 commented on a change in pull request #24994: [SPARK-28133] Adding inverse hyperbolic functions in SQL URL: https://github.com/apache/spark/pull/24994#discussion_r298755518 ## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala ## @@ -617,6 +659,27 @@ 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 + """) +case class Atanh(child: Expression) + extends UnaryMathExpression((x: Double) => 0.5 * math.log((1.0 + x) / (1.0 - x)), "ATANH") { Review comment: same as above. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org