-
Notifications
You must be signed in to change notification settings - Fork 29.2k
[SPARK-1995][SQL] system function upper and lower can be supported #936
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 2 commits
13d3267
1f0bbb5
b49f25e
ea76d0a
3c6c60a
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 |
|---|---|---|
|
|
@@ -70,6 +70,22 @@ trait StringRegexExpression { | |
| } | ||
| } | ||
|
|
||
| trait CaseConversionExpression { | ||
| self: UnaryExpression => | ||
|
|
||
| type EvaluatedType = Any | ||
|
|
||
| def convert(v: String): String | ||
|
|
||
| def nullable: Boolean = true | ||
| def dataType: DataType = StringType | ||
|
|
||
| override def eval(input: Row): Any = { | ||
| val beConverted = child.eval(input) | ||
|
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.
|
||
| convert(beConverted.toString) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Simple RegEx pattern matching function | ||
| */ | ||
|
|
@@ -115,3 +131,21 @@ case class RLike(left: Expression, right: Expression) | |
| override def escape(v: String): String = v | ||
| override def matches(regex: Pattern, str: String): Boolean = regex.matcher(str).find(0) | ||
| } | ||
|
|
||
| /** | ||
| * System function upper() | ||
|
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. Perhaps, "A function that converts the characters of a string to uppercase." |
||
| * */ | ||
|
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. Please remove the redundant leading |
||
| case class Upper(child: Expression) | ||
| extends UnaryExpression with CaseConversionExpression { | ||
|
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. Does this fit on one line? |
||
|
|
||
| override def convert(v: String): String = {v.toUpperCase()} | ||
|
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. Please either remove the braces or start the function body in a new line. |
||
| } | ||
|
|
||
| /** | ||
| * System function lower() | ||
| * */ | ||
|
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. Same as above. |
||
| case class Lower(child: Expression) | ||
| extends UnaryExpression with CaseConversionExpression { | ||
|
|
||
| override def convert(v: String): String = {v.toLowerCase()} | ||
|
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. Same as above. |
||
| } | ||
|
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. Please add a new line at the end of the file. |
||
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 it be null if the child is not nullable?