Uh oh!
There was an error while loading. Please reload this page.
[SPARK-17963][SQL][Documentation] Add examples (extend) in each expression and improve documentation with arguments - #15513
[SPARK-17963][SQL][Documentation] Add examples (extend) in each expression and improve documentation with arguments#15513HyukjinKwon wants to merge 47 commits into
Conversation
There was a problem hiding this comment.
documentation -> document?
xpath -> XPath
(Here and in a few other places)
There was a problem hiding this comment.
Nit: while we're here, should this say 'set' as well?
There was a problem hiding this comment.
Super nit but while you're changing this, there's no reason to capitalize skewness
There was a problem hiding this comment.
Same with kurtosis, they're not proper nouns
There was a problem hiding this comment.
Should this say 'list'? and it doesn't seem like they're unique, necessarily, given existing text?
There was a problem hiding this comment.
Oh, sorry, it was a typo. Yes, it should be list.
@srowen I will definitely double check the changes here before proceeding further. Thank you for your review before getting this too big. I will proceed this in 1-2 days. Please let me know if anyone feels the format looks not nice or should be fixed. |
srowen
commented
Oct 17, 2016
I suppose I don't know the conventions here well, but, the format looks better in your change, and more params documentation seems helpful. |
rxin
commented
Oct 17, 2016
I find this too verbose for the basic one. When looking at the basic one, I want an one-liner explanation because it can also show up in the entire list of UDFs. I'd put the detailed argument type, etc into the extended part, rather than in basic. |
SparkQA
commented
Oct 17, 2016
Test build #67071 has finished for PR 15513 at commit
|
Thank you @rxin, I just updated the PR description. I left the usage already having single-line usage as it was but just will indent the multiple line ones. Also, I moved the arguments and examples into extended part. Will proceed soon in few days in case the format should be fixed more. |
SparkQA
commented
Oct 18, 2016
Test build #67130 has finished for PR 15513 at commit
|
SparkQA
commented
Oct 19, 2016
Test build #67199 has finished for PR 15513 at commit
|
SparkQA
commented
Oct 19, 2016
Test build #67204 has finished for PR 15513 at commit
|
HyukjinKwon
commented
Oct 20, 2016
Oh, FWIW, this build seems being failed correctly in some tests. I will fix them just to prevent misleading. |
SparkQA
commented
Oct 20, 2016
Test build #3366 has finished for PR 15513 at commit
|
| extended = """ | ||
| Arguments: | ||
| expr1 - an expression of any type. | ||
| expr2 - an expression of any type. |
There was a problem hiding this comment.
Are you sure it can support any type?
For logical operations (AND, OR or others), I think the only acceptable types are boolean
There was a problem hiding this comment.
I should change. It was my mistake. Thanks!
gatorsmile
commented
Oct 26, 2016
Could you take another pass at changes? especially the argument types. I think this PR still has many related issues. |
I mostly ran it by myself when I was in doubt so I guess it'd be mostly okay. At least, one major issue was identified above, so I will definitely look into this closely again and be back soon. BTW, there were comments about argument description (not about a typo but semantic change), #15513 (comment), #15513 (comment), #15513 (comment), #15513 (comment), #15513 (comment), #15513 (comment) and #15513 (comment) (if I haven't missed a couple of ones). The valid ones are both #15513 (comment) and #15513 (comment) which I guess only one is the major one (inappropriate type) and the other one is minor (to take out the decimal type from numeric type). I guess this might not imply that it has many related issues about this. |
HyukjinKwon
commented
Oct 27, 2016
I will take another look closely as suggested and then will let you all know. |
SparkQA
commented
Oct 27, 2016
Test build #67612 has finished for PR 15513 at commit
|
SparkQA
commented
Oct 27, 2016
Test build #3376 has finished for PR 15513 at commit
|
HyukjinKwon
commented
Oct 27, 2016
I took another look and It seems generally fine. Could you take a look all? |
SparkQA
commented
Oct 27, 2016
Test build #67646 has finished for PR 15513 at commit
|
HyukjinKwon
commented
Oct 27, 2016
retest this please |
SparkQA
commented
Oct 28, 2016
Test build #67674 has finished for PR 15513 at commit
|
gatorsmile
commented
Oct 28, 2016
Will review it tomorrow. Thanks! |
Thanks @gatorsmile. Just FYI, I would like to note the rule I used for argument types (just to avoid extra efforts when you review). As we all know, I did not mention implicit casting as suggested. So, I kind of did the best efforts to describe this by using the abstract terms for types such as For example, If a function takes Another reason why I used this rule is, for the potential documentation update to mention implicit casting in the future. For example, would be easily updated as below: Another example would be.. This would be easily updated as below: |
| @ExpressionDescription( | ||
| usage = "_FUNC_(date, fmt) - Returns returns date with the time portion of the day truncated to the unit specified by the format model fmt.", | ||
| extended = "> SELECT _FUNC_('2009-02-12', 'MM')\n '2009-02-01'\n> SELECT _FUNC_('2015-10-27', 'YEAR');\n '2015-01-01'") | ||
| usage = "_FUNC_(date, fmt) - Returns returns `date` with the time portion of the day truncated to the unit specified by the format model `fmt`.", |
gatorsmile
commented
Oct 28, 2016
I still found a general issue in the type description.
|
Yes, I have. Could you point out an instance? I will fix them and double check the same instances. If wrong. |
| usage = "_FUNC_(expr AS type) - Casts the value `expr` to the target data type `type`.", | ||
| extended = """ | ||
| Arguments: | ||
| expr - an expression of any type. |
There was a problem hiding this comment.
spark-sql>SELECT cast(array(1) as string), cast(struct(1) as string), cast(map(1,1) as string);
[1] [1] keys: [1], values: [1]| """, | ||
| extended = """ | ||
| Arguments: | ||
| expr - an expression of any type that represents data to count. |
There was a problem hiding this comment.
spark-sql>SELECTcount(array(1)), count(struct(1)), count(map(1,1));
111| """, | ||
| extended = """ | ||
| Arguments: | ||
| expr - an expression of any type that represents data to collect the first. |
There was a problem hiding this comment.
spark-sql>SELECT first(array(1)), first(struct(1)), first(map(1,1));
[1] {"col1":1} {1:1}| """, | ||
| extended = """ | ||
| Arguments: | ||
| expr - an expression of any type that represents data to count. |
There was a problem hiding this comment.
spark-sql>SELECT approx_count_distinct(array(1)), approx_count_distinct(struct(1)), approx_count_distinct(map(1,1));
111| usage = "_FUNC_(expr) - Collects and returns a list of non-unique elements.", | ||
| extended = """ | ||
| Arguments: | ||
| expr - an expression of any type that represents data to collect as a list. |
There was a problem hiding this comment.
spark-sql>SELECT collect_list(array(1)), collect_list(struct(1)), collect_list(map(1, 1));
[[1]] [{"col1":1}] [{1:1}]| extended = """ | ||
| Arguments: | ||
| expr1 - an expression of any type. | ||
| expr2 - an expression of any type. |
There was a problem hiding this comment.
spark-sql>SELECT array(1) = array(1), struct(1) = struct(1), map(1, 1) = map(1, 1);
true true false| extended = """ | ||
| Arguments: | ||
| expr1 - an expression of any type. | ||
| expr2 - an expression of any type. |
There was a problem hiding this comment.
spark-sql>SELECT array(1) <=> array(1), struct(1) <=> struct(1), map(1, 1) <=> map(1, 1);
true true false| extended = """ | ||
| Arguments: | ||
| strfmt - a string expression. | ||
| obj - an expression of any type. |
There was a problem hiding this comment.
spark-sql>SELECT format_string("Hello World %d %s", 100, array(1), struct(1), map(1, 1));
Hello World 100 [1]| input - an expression of any type. | ||
| offset - a numeric expression. Default is 1. | ||
| default - an expression of any type. Default is null. | ||
| """) |
There was a problem hiding this comment.
{
valdf=Seq((1, "1"), (2, "2"), (1, "1"), (2, "2")).toDF("key", "value")
.selectExpr("array(value) as value", "key")
df.select(
lead("value", 1).over(Window.partitionBy($"key").orderBy($"value"))).show()
}
{
valdf=Seq((1, "1"), (2, "2"), (1, "1"), (2, "2")).toDF("key", "value")
.selectExpr("struct(value) as value", "key")
df.select(
lead("value", 1).over(Window.partitionBy($"key").orderBy($"value"))).show()
}| Arguments: | ||
| input - an expression of any type. | ||
| offset - a numeric expression. Default is 1. | ||
| default - an expression of any type. Default is null. |
There was a problem hiding this comment.
{
valdf=Seq((1, "1"), (2, "2"), (1, "1"), (2, "2")).toDF("key", "value")
.selectExpr("array(value) as value", "key")
df.select(
lag("value", 1).over(Window.partitionBy($"key").orderBy($"value"))).show()
}
{
valdf=Seq((1, "1"), (2, "2"), (1, "1"), (2, "2")).toDF("key", "value")
.selectExpr("struct(value) as value", "key")
df.select(
lag("value", 1).over(Window.partitionBy($"key").orderBy($"value"))).show()
}Let me close and reopen another. It seems really messy. |
SparkQA
commented
Oct 29, 2016
Test build #67732 has finished for PR 15513 at commit
|
…ssion and improve documentation ## What changes were proposed in this pull request? This PR proposes to change the documentation for functions. Please refer the discussion from #15513 The changes include - Re-indent the documentation - Add examples/arguments in `extended` where the arguments are multiple or specific format (e.g. xml/ json). For examples, the documentation was updated as below: ### Functions with single line usage **Before** - `pow` ``` sql Usage: pow(x1, x2) - Raise x1 to the power of x2. Extended Usage: > SELECT pow(2, 3); 8.0 ``` - `current_timestamp` ``` sql Usage: current_timestamp() - Returns the current timestamp at the start of query evaluation. Extended Usage: No example for current_timestamp. ``` **After** - `pow` ``` sql Usage: pow(expr1, expr2) - Raises `expr1` to the power of `expr2`. Extended Usage: Examples: > SELECT pow(2, 3); 8.0 ``` - `current_timestamp` ``` sql Usage: current_timestamp() - Returns the current timestamp at the start of query evaluation. Extended Usage: No example/argument for current_timestamp. ``` ### Functions with (already) multiple line usage **Before** - `approx_count_distinct` ``` sql Usage: approx_count_distinct(expr) - Returns the estimated cardinality by HyperLogLog++. approx_count_distinct(expr, relativeSD=0.05) - Returns the estimated cardinality by HyperLogLog++ with relativeSD, the maximum estimation error allowed. Extended Usage: No example for approx_count_distinct. ``` - `percentile_approx` ``` sql Usage: percentile_approx(col, percentage [, accuracy]) - Returns the approximate percentile value of numeric column `col` at the given percentage. The value of percentage must be between 0.0 and 1.0. The `accuracy` parameter (default: 10000) is a positive integer literal which controls approximation accuracy at the cost of memory. Higher value of `accuracy` yields better accuracy, `1.0/accuracy` is the relative error of the approximation. percentile_approx(col, array(percentage1 [, percentage2]...) [, accuracy]) - Returns the approximate percentile array of column `col` at the given percentage array. Each value of the percentage array must be between 0.0 and 1.0. The `accuracy` parameter (default: 10000) is a positive integer literal which controls approximation accuracy at the cost of memory. Higher value of `accuracy` yields better accuracy, `1.0/accuracy` is the relative error of the approximation. Extended Usage: No example for percentile_approx. ``` **After** - `approx_count_distinct` ``` sql Usage: approx_count_distinct(expr[, relativeSD]) - Returns the estimated cardinality by HyperLogLog++. `relativeSD` defines the maximum estimation error allowed. Extended Usage: No example/argument for approx_count_distinct. ``` - `percentile_approx` ``` sql Usage: percentile_approx(col, percentage [, accuracy]) - Returns the approximate percentile value of numeric column `col` at the given percentage. The value of percentage must be between 0.0 and 1.0. The `accuracy` parameter (default: 10000) is a positive numeric literal which controls approximation accuracy at the cost of memory. Higher value of `accuracy` yields better accuracy, `1.0/accuracy` is the relative error of the approximation. When `percentage` is an array, each value of the percentage array must be between 0.0 and 1.0. In this case, returns the approximate percentile array of column `col` at the given percentage array. Extended Usage: Examples: > SELECT percentile_approx(10.0, array(0.5, 0.4, 0.1), 100); [10.0,10.0,10.0] > SELECT percentile_approx(10.0, 0.5, 100); 10.0 ``` ## How was this patch tested? Manually tested **When examples are multiple** ``` sql spark-sql> describe function extended reflect; Function: reflect Class: org.apache.spark.sql.catalyst.expressions.CallMethodViaReflection Usage: reflect(class, method[, arg1[, arg2 ..]]) - Calls a method with reflection. Extended Usage: Examples: > SELECT reflect('java.util.UUID', 'randomUUID'); c33fb387-8500-4bfa-81d2-6e0e3e930df2 > SELECT reflect('java.util.UUID', 'fromString', 'a5cf6c42-0c85-418f-af6c-3e4e5b1328f2'); a5cf6c42-0c85-418f-af6c-3e4e5b1328f2 ``` **When `Usage` is in single line** ``` sql spark-sql> describe function extended min; Function: min Class: org.apache.spark.sql.catalyst.expressions.aggregate.Min Usage: min(expr) - Returns the minimum value of `expr`. Extended Usage: No example/argument for min. ``` **When `Usage` is already in multiple lines** ``` sql spark-sql> describe function extended percentile_approx; Function: percentile_approx Class: org.apache.spark.sql.catalyst.expressions.aggregate.ApproximatePercentile Usage: percentile_approx(col, percentage [, accuracy]) - Returns the approximate percentile value of numeric column `col` at the given percentage. The value of percentage must be between 0.0 and 1.0. The `accuracy` parameter (default: 10000) is a positive numeric literal which controls approximation accuracy at the cost of memory. Higher value of `accuracy` yields better accuracy, `1.0/accuracy` is the relative error of the approximation. When `percentage` is an array, each value of the percentage array must be between 0.0 and 1.0. In this case, returns the approximate percentile array of column `col` at the given percentage array. Extended Usage: Examples: > SELECT percentile_approx(10.0, array(0.5, 0.4, 0.1), 100); [10.0,10.0,10.0] > SELECT percentile_approx(10.0, 0.5, 100); 10.0 ``` **When example/argument is missing** ``` sql spark-sql> describe function extended rank; Function: rank Class: org.apache.spark.sql.catalyst.expressions.Rank Usage: rank() - Computes the rank of a value in a group of values. The result is one plus the number of rows preceding or equal to the current row in the ordering of the partition. The values will produce gaps in the sequence. Extended Usage: No example/argument for rank. ``` Author: hyukjinkwon <gurwls223@gmail.com> Closes#15677 from HyukjinKwon/SPARK-17963-1. (cherry picked from commit 7eb2ca8) Signed-off-by: gatorsmile <gatorsmile@gmail.com>
…ssion and improve documentation ## What changes were proposed in this pull request? This PR proposes to change the documentation for functions. Please refer the discussion from #15513 The changes include - Re-indent the documentation - Add examples/arguments in `extended` where the arguments are multiple or specific format (e.g. xml/ json). For examples, the documentation was updated as below: ### Functions with single line usage **Before** - `pow` ``` sql Usage: pow(x1, x2) - Raise x1 to the power of x2. Extended Usage: > SELECT pow(2, 3); 8.0 ``` - `current_timestamp` ``` sql Usage: current_timestamp() - Returns the current timestamp at the start of query evaluation. Extended Usage: No example for current_timestamp. ``` **After** - `pow` ``` sql Usage: pow(expr1, expr2) - Raises `expr1` to the power of `expr2`. Extended Usage: Examples: > SELECT pow(2, 3); 8.0 ``` - `current_timestamp` ``` sql Usage: current_timestamp() - Returns the current timestamp at the start of query evaluation. Extended Usage: No example/argument for current_timestamp. ``` ### Functions with (already) multiple line usage **Before** - `approx_count_distinct` ``` sql Usage: approx_count_distinct(expr) - Returns the estimated cardinality by HyperLogLog++. approx_count_distinct(expr, relativeSD=0.05) - Returns the estimated cardinality by HyperLogLog++ with relativeSD, the maximum estimation error allowed. Extended Usage: No example for approx_count_distinct. ``` - `percentile_approx` ``` sql Usage: percentile_approx(col, percentage [, accuracy]) - Returns the approximate percentile value of numeric column `col` at the given percentage. The value of percentage must be between 0.0 and 1.0. The `accuracy` parameter (default: 10000) is a positive integer literal which controls approximation accuracy at the cost of memory. Higher value of `accuracy` yields better accuracy, `1.0/accuracy` is the relative error of the approximation. percentile_approx(col, array(percentage1 [, percentage2]...) [, accuracy]) - Returns the approximate percentile array of column `col` at the given percentage array. Each value of the percentage array must be between 0.0 and 1.0. The `accuracy` parameter (default: 10000) is a positive integer literal which controls approximation accuracy at the cost of memory. Higher value of `accuracy` yields better accuracy, `1.0/accuracy` is the relative error of the approximation. Extended Usage: No example for percentile_approx. ``` **After** - `approx_count_distinct` ``` sql Usage: approx_count_distinct(expr[, relativeSD]) - Returns the estimated cardinality by HyperLogLog++. `relativeSD` defines the maximum estimation error allowed. Extended Usage: No example/argument for approx_count_distinct. ``` - `percentile_approx` ``` sql Usage: percentile_approx(col, percentage [, accuracy]) - Returns the approximate percentile value of numeric column `col` at the given percentage. The value of percentage must be between 0.0 and 1.0. The `accuracy` parameter (default: 10000) is a positive numeric literal which controls approximation accuracy at the cost of memory. Higher value of `accuracy` yields better accuracy, `1.0/accuracy` is the relative error of the approximation. When `percentage` is an array, each value of the percentage array must be between 0.0 and 1.0. In this case, returns the approximate percentile array of column `col` at the given percentage array. Extended Usage: Examples: > SELECT percentile_approx(10.0, array(0.5, 0.4, 0.1), 100); [10.0,10.0,10.0] > SELECT percentile_approx(10.0, 0.5, 100); 10.0 ``` ## How was this patch tested? Manually tested **When examples are multiple** ``` sql spark-sql> describe function extended reflect; Function: reflect Class: org.apache.spark.sql.catalyst.expressions.CallMethodViaReflection Usage: reflect(class, method[, arg1[, arg2 ..]]) - Calls a method with reflection. Extended Usage: Examples: > SELECT reflect('java.util.UUID', 'randomUUID'); c33fb387-8500-4bfa-81d2-6e0e3e930df2 > SELECT reflect('java.util.UUID', 'fromString', 'a5cf6c42-0c85-418f-af6c-3e4e5b1328f2'); a5cf6c42-0c85-418f-af6c-3e4e5b1328f2 ``` **When `Usage` is in single line** ``` sql spark-sql> describe function extended min; Function: min Class: org.apache.spark.sql.catalyst.expressions.aggregate.Min Usage: min(expr) - Returns the minimum value of `expr`. Extended Usage: No example/argument for min. ``` **When `Usage` is already in multiple lines** ``` sql spark-sql> describe function extended percentile_approx; Function: percentile_approx Class: org.apache.spark.sql.catalyst.expressions.aggregate.ApproximatePercentile Usage: percentile_approx(col, percentage [, accuracy]) - Returns the approximate percentile value of numeric column `col` at the given percentage. The value of percentage must be between 0.0 and 1.0. The `accuracy` parameter (default: 10000) is a positive numeric literal which controls approximation accuracy at the cost of memory. Higher value of `accuracy` yields better accuracy, `1.0/accuracy` is the relative error of the approximation. When `percentage` is an array, each value of the percentage array must be between 0.0 and 1.0. In this case, returns the approximate percentile array of column `col` at the given percentage array. Extended Usage: Examples: > SELECT percentile_approx(10.0, array(0.5, 0.4, 0.1), 100); [10.0,10.0,10.0] > SELECT percentile_approx(10.0, 0.5, 100); 10.0 ``` **When example/argument is missing** ``` sql spark-sql> describe function extended rank; Function: rank Class: org.apache.spark.sql.catalyst.expressions.Rank Usage: rank() - Computes the rank of a value in a group of values. The result is one plus the number of rows preceding or equal to the current row in the ordering of the partition. The values will produce gaps in the sequence. Extended Usage: No example/argument for rank. ``` Author: hyukjinkwon <gurwls223@gmail.com> Closes#15677 from HyukjinKwon/SPARK-17963-1.
…ssion and improve documentation ## What changes were proposed in this pull request? This PR proposes to change the documentation for functions. Please refer the discussion from apache#15513 The changes include - Re-indent the documentation - Add examples/arguments in `extended` where the arguments are multiple or specific format (e.g. xml/ json). For examples, the documentation was updated as below: ### Functions with single line usage **Before** - `pow` ``` sql Usage: pow(x1, x2) - Raise x1 to the power of x2. Extended Usage: > SELECT pow(2, 3); 8.0 ``` - `current_timestamp` ``` sql Usage: current_timestamp() - Returns the current timestamp at the start of query evaluation. Extended Usage: No example for current_timestamp. ``` **After** - `pow` ``` sql Usage: pow(expr1, expr2) - Raises `expr1` to the power of `expr2`. Extended Usage: Examples: > SELECT pow(2, 3); 8.0 ``` - `current_timestamp` ``` sql Usage: current_timestamp() - Returns the current timestamp at the start of query evaluation. Extended Usage: No example/argument for current_timestamp. ``` ### Functions with (already) multiple line usage **Before** - `approx_count_distinct` ``` sql Usage: approx_count_distinct(expr) - Returns the estimated cardinality by HyperLogLog++. approx_count_distinct(expr, relativeSD=0.05) - Returns the estimated cardinality by HyperLogLog++ with relativeSD, the maximum estimation error allowed. Extended Usage: No example for approx_count_distinct. ``` - `percentile_approx` ``` sql Usage: percentile_approx(col, percentage [, accuracy]) - Returns the approximate percentile value of numeric column `col` at the given percentage. The value of percentage must be between 0.0 and 1.0. The `accuracy` parameter (default: 10000) is a positive integer literal which controls approximation accuracy at the cost of memory. Higher value of `accuracy` yields better accuracy, `1.0/accuracy` is the relative error of the approximation. percentile_approx(col, array(percentage1 [, percentage2]...) [, accuracy]) - Returns the approximate percentile array of column `col` at the given percentage array. Each value of the percentage array must be between 0.0 and 1.0. The `accuracy` parameter (default: 10000) is a positive integer literal which controls approximation accuracy at the cost of memory. Higher value of `accuracy` yields better accuracy, `1.0/accuracy` is the relative error of the approximation. Extended Usage: No example for percentile_approx. ``` **After** - `approx_count_distinct` ``` sql Usage: approx_count_distinct(expr[, relativeSD]) - Returns the estimated cardinality by HyperLogLog++. `relativeSD` defines the maximum estimation error allowed. Extended Usage: No example/argument for approx_count_distinct. ``` - `percentile_approx` ``` sql Usage: percentile_approx(col, percentage [, accuracy]) - Returns the approximate percentile value of numeric column `col` at the given percentage. The value of percentage must be between 0.0 and 1.0. The `accuracy` parameter (default: 10000) is a positive numeric literal which controls approximation accuracy at the cost of memory. Higher value of `accuracy` yields better accuracy, `1.0/accuracy` is the relative error of the approximation. When `percentage` is an array, each value of the percentage array must be between 0.0 and 1.0. In this case, returns the approximate percentile array of column `col` at the given percentage array. Extended Usage: Examples: > SELECT percentile_approx(10.0, array(0.5, 0.4, 0.1), 100); [10.0,10.0,10.0] > SELECT percentile_approx(10.0, 0.5, 100); 10.0 ``` ## How was this patch tested? Manually tested **When examples are multiple** ``` sql spark-sql> describe function extended reflect; Function: reflect Class: org.apache.spark.sql.catalyst.expressions.CallMethodViaReflection Usage: reflect(class, method[, arg1[, arg2 ..]]) - Calls a method with reflection. Extended Usage: Examples: > SELECT reflect('java.util.UUID', 'randomUUID'); c33fb387-8500-4bfa-81d2-6e0e3e930df2 > SELECT reflect('java.util.UUID', 'fromString', 'a5cf6c42-0c85-418f-af6c-3e4e5b1328f2'); a5cf6c42-0c85-418f-af6c-3e4e5b1328f2 ``` **When `Usage` is in single line** ``` sql spark-sql> describe function extended min; Function: min Class: org.apache.spark.sql.catalyst.expressions.aggregate.Min Usage: min(expr) - Returns the minimum value of `expr`. Extended Usage: No example/argument for min. ``` **When `Usage` is already in multiple lines** ``` sql spark-sql> describe function extended percentile_approx; Function: percentile_approx Class: org.apache.spark.sql.catalyst.expressions.aggregate.ApproximatePercentile Usage: percentile_approx(col, percentage [, accuracy]) - Returns the approximate percentile value of numeric column `col` at the given percentage. The value of percentage must be between 0.0 and 1.0. The `accuracy` parameter (default: 10000) is a positive numeric literal which controls approximation accuracy at the cost of memory. Higher value of `accuracy` yields better accuracy, `1.0/accuracy` is the relative error of the approximation. When `percentage` is an array, each value of the percentage array must be between 0.0 and 1.0. In this case, returns the approximate percentile array of column `col` at the given percentage array. Extended Usage: Examples: > SELECT percentile_approx(10.0, array(0.5, 0.4, 0.1), 100); [10.0,10.0,10.0] > SELECT percentile_approx(10.0, 0.5, 100); 10.0 ``` **When example/argument is missing** ``` sql spark-sql> describe function extended rank; Function: rank Class: org.apache.spark.sql.catalyst.expressions.Rank Usage: rank() - Computes the rank of a value in a group of values. The result is one plus the number of rows preceding or equal to the current row in the ordering of the partition. The values will produce gaps in the sequence. Extended Usage: No example/argument for rank. ``` Author: hyukjinkwon <gurwls223@gmail.com> Closesapache#15677 from HyukjinKwon/SPARK-17963-1.
What changes were proposed in this pull request?
This PR proposes to change the documentation for functions.
The changes include
extendedwhere the arguments are multiple or specific format (e.g. xml/ json).For examples, the documentation was updated as below:
Functions with single line usage
Before
powcurrent_timestampAfter
powcurrent_timestampFunctions with (already) multiple line usage
Before
approx_count_distinctpercentile_approxAfter
approx_count_distinctpercentile_approxHow was this patch tested?
Manually tested
When examples are multiple
When
Usageis in single lineWhen
Usageis already in multiple linesWhen example/argument is missing