-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-12457] [SQL] Add ExpressionDescription to collection functions. #10418
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
Closed
Closed
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e49b036
Add ExpressionDescription to collection functions.
gatorsmile 8aa414e
Merge remote-tracking branch 'upstream/master' into ExpDesc4C
gatorsmile c03371c
address comments.
gatorsmile afdcb1c
added three test cases.
gatorsmile 99cb7d8
use triple quotes.
gatorsmile 64f32a4
address the comments.
gatorsmile File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,9 @@ import org.apache.spark.sql.types._ | |
| /** | ||
| * Given an array or map, returns its size. | ||
| */ | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(column) - Returns the length of the array or map stored in the column", | ||
| extended = "> SELECT _FUNC_(array(\"b\", \"d\", \"c\", \"a\"));\n 4") | ||
| case class Size(child: Expression) extends UnaryExpression with ExpectsInputTypes { | ||
| override def dataType: DataType = IntegerType | ||
| override def inputTypes: Seq[AbstractDataType] = Seq(TypeCollection(ArrayType, MapType)) | ||
|
|
@@ -44,6 +47,11 @@ case class Size(child: Expression) extends UnaryExpression with ExpectsInputType | |
| * Sorts the input array in ascending / descending order according to the natural ordering of | ||
| * the array elements and returns it. | ||
| */ | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(array, ascendingOrder) - Sorts the input array for the given column in " + | ||
|
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. This will fail to compile in scala 2.11. Use a multiline string here, see: #10488
Member
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. Thank you, I will change all of them. |
||
| "ascending / descending order, according to the natural ordering of the array elements", | ||
| extended = "> SELECT _FUNC_(array(\"b\", \"d\", \"c\", \"a\"), false);\n " + | ||
| "[\"d\",\"c\",\"b\",\"a\"]") | ||
| case class SortArray(base: Expression, ascendingOrder: Expression) | ||
| extends BinaryExpression with ExpectsInputTypes with CodegenFallback { | ||
|
|
||
|
|
@@ -125,6 +133,9 @@ case class SortArray(base: Expression, ascendingOrder: Expression) | |
| /** | ||
| * Checks if the array (left) has the element (right) | ||
| */ | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(array, value) - Returns true if the array contains the value", | ||
| extended = "> SELECT _FUNC_(array(2, 9, 8), 9);\n true") | ||
| case class ArrayContains(left: Expression, right: Expression) | ||
| extends BinaryExpression with ImplicitCastInputTypes { | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit: i would use triple quotes for strings that contain quotes
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.
Tried to do it, but realized annotation argument needs to be a constant. A newline marker
\nis an issue here. We are unable to callstripMarginafter triple quotes. Thus, I calledstripMarginwhen buildingExpressionInfo. Do you like it?