-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-23329][SQL] Fix documentation of trigonometric functions #20618
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
0a0c4ae
168d7b3
2586b0f
8550a27
40da998
0e4e15a
fcf1338
2ea1f18
10afda5
627e204
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 |
|---|---|---|
|
|
@@ -168,41 +168,44 @@ case class Pi() extends LeafMathExpression(math.Pi, "PI") | |
| //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
| // scalastyle:off line.size.limit | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the inverse cosine (a.k.a. arccosine) of `expr` if -1<=`expr`<=1 or NaN otherwise.", | ||
| usage = """ | ||
| _FUNC_(expr) - Returns the inverse cosine (a.k.a. arc cosine) of `expr`, as if computed by | ||
| `java.lang.Math._FUNC_`. | ||
| """, | ||
| examples = """ | ||
| Examples: | ||
| > SELECT _FUNC_(1); | ||
| 0.0 | ||
| > SELECT _FUNC_(2); | ||
| NaN | ||
| """) | ||
| // scalastyle:on line.size.limit | ||
| case class Acos(child: Expression) extends UnaryMathExpression(math.acos, "ACOS") | ||
|
|
||
| // scalastyle:off line.size.limit | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the inverse sine (a.k.a. arcsine) the arc sin of `expr` if -1<=`expr`<=1 or NaN otherwise.", | ||
| usage = """ | ||
| _FUNC_(expr) - Returns the inverse sine (a.k.a. arc sine) the arc sin of `expr`, | ||
| as if computed by `java.lang.Math._FUNC_`. | ||
| """, | ||
| examples = """ | ||
| Examples: | ||
| > SELECT _FUNC_(0); | ||
| 0.0 | ||
| > SELECT _FUNC_(2); | ||
| NaN | ||
| """) | ||
| // scalastyle:on line.size.limit | ||
| case class Asin(child: Expression) extends UnaryMathExpression(math.asin, "ASIN") | ||
|
|
||
| // scalastyle:off line.size.limit | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the inverse tangent (a.k.a. arctangent).", | ||
| usage = """ | ||
| _FUNC_(expr) - Returns the inverse tangent (a.k.a. arc tangent) of `expr`, as if computed by | ||
| `java.lang.Math._FUNC_` | ||
| """, | ||
| examples = """ | ||
| Examples: | ||
| > SELECT _FUNC_(0); | ||
| 0.0 | ||
| """) | ||
| // scalastyle:on line.size.limit | ||
| case class Atan(child: Expression) extends UnaryMathExpression(math.atan, "ATAN") | ||
|
|
||
| @ExpressionDescription( | ||
|
|
@@ -252,7 +255,14 @@ case class Ceil(child: Expression) extends UnaryMathExpression(math.ceil, "CEIL" | |
| } | ||
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the cosine of `expr`.", | ||
| usage = """ | ||
| _FUNC_(expr) - Returns the cosine of `expr`, as if computed by | ||
| `java.lang.Math._FUNC_`. | ||
| """, | ||
| arguments = """ | ||
| Arguments: | ||
| * expr - angle in radians | ||
| """, | ||
| examples = """ | ||
| Examples: | ||
| > SELECT _FUNC_(0); | ||
|
|
@@ -262,6 +272,10 @@ case class Cos(child: Expression) extends UnaryMathExpression(math.cos, "COS") | |
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the hyperbolic cosine of `expr`.", | ||
|
||
| arguments = """ | ||
| Arguments: | ||
| * expr - hyperbolic angle. | ||
|
||
| """, | ||
| examples = """ | ||
| Examples: | ||
| > SELECT _FUNC_(0); | ||
|
|
@@ -512,7 +526,11 @@ case class Rint(child: Expression) extends UnaryMathExpression(math.rint, "ROUND | |
| case class Signum(child: Expression) extends UnaryMathExpression(math.signum, "SIGNUM") | ||
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the sine of `expr`.", | ||
| usage = "_FUNC_(expr) - Returns the sine of `expr`, as if computed by `java.lang.Math._FUNC_`.", | ||
|
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 don't know the history of why the text is different here vs python/R https://github.com/apache/spark/blob/master/R/pkg/R/functions.R#L1466 I don't think the doc grouping in R is relevant - the text is there. Generally we try to match the text in scala but I don't feel strongly either way in this case.
Contributor
Author
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 far as the trigonometric functions concerned they should be now in sync I think. |
||
| arguments = """ | ||
| Arguments: | ||
| * expr - angle in radians | ||
| """, | ||
| examples = """ | ||
| Examples: | ||
| > SELECT _FUNC_(0); | ||
|
|
@@ -521,7 +539,13 @@ case class Signum(child: Expression) extends UnaryMathExpression(math.signum, "S | |
| case class Sin(child: Expression) extends UnaryMathExpression(math.sin, "SIN") | ||
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the hyperbolic sine of `expr`.", | ||
| usage = """ | ||
| _FUNC_(expr) - Returns hyperbolic sine of `expr`, as if computed by `java.lang.Math._FUNC_`. | ||
| """, | ||
| arguments = """ | ||
| Arguments: | ||
| * expr - hyperbolic angle | ||
| """, | ||
| examples = """ | ||
| Examples: | ||
| > SELECT _FUNC_(0); | ||
|
|
@@ -539,7 +563,14 @@ case class Sinh(child: Expression) extends UnaryMathExpression(math.sinh, "SINH" | |
| case class Sqrt(child: Expression) extends UnaryMathExpression(math.sqrt, "SQRT") | ||
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the tangent of `expr`.", | ||
| usage = """ | ||
| _FUNC_(expr) - Returns the tangent of `expr`, as if computed by | ||
| `java.lang.Math._FUNC_`. | ||
|
||
| """, | ||
| arguments = """ | ||
| Arguments: | ||
| * expr - angle in radians | ||
| """, | ||
| examples = """ | ||
| Examples: | ||
| > SELECT _FUNC_(0); | ||
|
|
@@ -548,7 +579,14 @@ case class Sqrt(child: Expression) extends UnaryMathExpression(math.sqrt, "SQRT" | |
| case class Tan(child: Expression) extends UnaryMathExpression(math.tan, "TAN") | ||
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the cotangent of `expr`.", | ||
| usage = """ | ||
| _FUNC_(expr) - Returns the cotangent of `expr`, as if computed by | ||
| `1/java.lang.Math._FUNC_`. | ||
|
||
| """, | ||
| arguments = """ | ||
| Arguments: | ||
| * expr - angle in radians | ||
| """, | ||
| examples = """ | ||
| Examples: | ||
| > SELECT _FUNC_(1); | ||
|
|
@@ -562,7 +600,14 @@ case class Cot(child: Expression) | |
| } | ||
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the hyperbolic tangent of `expr`.", | ||
| usage = """ | ||
| _FUNC_(expr) - Returns the hyperbolic tangent of `expr`, as if computed by | ||
| `java.lang.Math._FUNC_`. | ||
| """, | ||
| arguments = """ | ||
| Arguments: | ||
| * expr - hyperbolic angle | ||
| """, | ||
| examples = """ | ||
| Examples: | ||
| > SELECT _FUNC_(0); | ||
|
|
@@ -572,6 +617,10 @@ case class Tanh(child: Expression) extends UnaryMathExpression(math.tanh, "TANH" | |
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Converts radians to degrees.", | ||
| arguments = """ | ||
| Arguments: | ||
| * expr - angle in radians | ||
| """, | ||
| examples = """ | ||
| Examples: | ||
| > SELECT _FUNC_(3.141592653589793); | ||
|
|
@@ -583,6 +632,10 @@ case class ToDegrees(child: Expression) extends UnaryMathExpression(math.toDegre | |
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Converts degrees to radians.", | ||
| arguments = """ | ||
| Arguments: | ||
| * expr - angle in degrees | ||
| """, | ||
| examples = """ | ||
| Examples: | ||
| > SELECT _FUNC_(180); | ||
|
|
@@ -768,15 +821,22 @@ case class Unhex(child: Expression) extends UnaryExpression with ImplicitCastInp | |
| //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
| // scalastyle:off line.size.limit | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr1, expr2) - Returns the angle in radians between the positive x-axis of a plane and the point given by the coordinates (`expr1`, `expr2`).", | ||
|
||
| usage = """ | ||
| _FUNC_(exprY, exprX) - Returns the angle in radians between the positive x-axis of a plane | ||
| and the point given by the coordinates (`exprX`, `exprY`), as if computed by | ||
| `java.lang.Math._FUNC_`. | ||
| """, | ||
| arguments = """ | ||
| Arguments: | ||
| * exprY - coordinate on y-axis | ||
| * exprX - coordinate on x-axis | ||
| """, | ||
| examples = """ | ||
| Examples: | ||
| > SELECT _FUNC_(0, 0); | ||
| 0.0 | ||
| """) | ||
| // scalastyle:on line.size.limit | ||
| case class Atan2(left: Expression, right: Expression) | ||
| extends BinaryMathExpression(math.atan2, "ATAN2") { | ||
|
|
||
|
|
||
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.
Let's remote two spaces ->
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.
yes, indeed that is used elsewhere