-
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 1 commit
0a0c4ae
168d7b3
2586b0f
8550a27
40da998
0e4e15a
fcf1338
2ea1f18
10afda5
627e204
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -170,7 +170,7 @@ 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); | ||||||||||||||||||||||||||||
|
|
@@ -183,7 +183,7 @@ 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); | ||||||||||||||||||||||||||||
|
|
@@ -196,7 +196,7 @@ 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); | ||||||||||||||||||||||||||||
|
|
@@ -252,7 +252,12 @@ 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 +267,11 @@ case class Cos(child: Expression) extends UnaryMathExpression(math.cos, "COS") | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| @ExpressionDescription( | ||||||||||||||||||||||||||||
| usage = "_FUNC_(expr) - Returns the hyperbolic cosine of `expr`.", | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| arguments = | ||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| arguments = """ | |
| Arguments: | |
| * str - a string expression | |
| * regexp - a string expression. The pattern string should be a Java regular expression. | |
| Since Spark 2.0, string literals (including regex patterns) are unescaped in our SQL | |
| parser. For example, to match "\abc", a regular expression for `regexp` can be | |
| "^\\abc$". | |
| There is a SQL config 'spark.sql.parser.escapedStringLiterals' that can be used to | |
| fallback to the Spark 1.6 behavior regarding string literal parsing. For example, | |
| if the config is enabled, the `regexp` that can match "\abc" is "^\abc$". | |
| """, |
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.
You are right, I will fix this.
Outdated
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.
not a big deal but let's remove the trailing . for consistency.
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.
ok
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.
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.
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.
As far as the trigonometric functions concerned they should be now in sync I think.
Outdated
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.
Can we have the same format for it and the same instances - #20618 (comment)?
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, I applied to all places in scope.
Outdated
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.
I think we should turn this on again
Outdated
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.
Ditto for turning it on
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.
Turned it on for all trigonometric functions.
Outdated
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.
Ditto for formatting
Outdated
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.
Seems line limit is reached here.
Outdated
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.
It looks like the declaration of atan2 should group with the trig functions. I think that's OK to fix here.
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.
I believe this should still be moved with this change.
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.
Now I got it. Sorry, earlier I just misunderstood it. Are you proposing to move this case class inside the file to be next to the other trigonometric function? Based on the comments it seems the functions are group based on the number of arguments. This function has 2 arguments that is why it is under // Binary math functions section. Even though this does not seem to create big cohesion inside such a group I guess we do not want to reorganize the file now?
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.
Oh, I get it now, that's my mistake. "Binary" means "two arg" and not perhaps "bitwise" or something. Leave it then.
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.
Seems unrelated change. Could we just revert this back?
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.
Sure
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.
Ditto for revert
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