-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-14878][SQL] Adding examples for Trim characters string function #19302
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
Conversation
|
You need a new JIRA |
| _FUNC_(BOTH trimStr FROM str) - Remove the leading and trailing trimString from `str` | ||
| _FUNC_(BOTH trimStr FROM str) - Remove the leading and trailing `trimStr` characters from `str` | ||
| _FUNC_(LEADING trimStr FROM str) - Remove the leading `trimStr` characters from `str` | ||
| _FUNC_(TRAILING trimStr FROM str) - Remove the trailing `trimStr` characters from `str` |
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.
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 see, thanks for finding this. I put the extra line there, then run this below
cd sql
create-docs.sh
it generate doc like this.
trim
trim(str) - Removes the leading and trailing space characters from str
trim(BOTH trimStr FROM str) - Remove the leading and trailing trimStr characters from str
trim(LEADING trimStr FROM str) - Remove the leading trimStr characters from str
trim(TRAILING trimStr FROM str) - Remove the trailing trimStr characters from str
and this is how describe function show:
spark-sql> describe function extended trim;
Function: trim
Class: org.apache.spark.sql.catalyst.expressions.StringTrim
Usage:
trim(str) - Removes the leading and trailing space characters from `str`
trim(BOTH trimStr FROM str) - Remove the leading and trailing `trimStr` characters from `str`
trim(LEADING trimStr FROM str) - Remove the leading `trimStr` characters from `str`
trim(TRAILING trimStr FROM str) - Remove the trailing `trimStr` characters from `str`
Extended Usage:
Arguments:
* str - a string expression
* trimStr - the trim string characters to trim, the default value is a single space
* BOTH, FROM - these are keywords to specify trimming string characters from both ends of the string
* LEADING, FROM - these are keywords to specify trimming string characters from the left end of the string
* TRAILING, FROM - these are keywords to specify trimming string characters from the right end of the string
Examples:
> SELECT trim(' SparkSQL ');
SparkSQL
> SELECT trim('SL', 'SSparkSQLS');
parkSQ
> SELECT trim(BOTH 'SL' FROM 'SSparkSQLS');
parkSQ
> SELECT trim(LEADING 'SL' FROM 'SSparkSQLS');
parkSQLS
> SELECT trim(TRAILING 'SL' FROM 'SSparkSQLS');
SSparkSQ
Time taken: 1.924 seconds, Fetched 4 row(s)
17/09/22 01:06:39 INFO SparkSQLCLIDriver: Time taken: 1.924 seconds, Fetched 4 row(s)
|
@srowen sure, I will open a new JIRA for this. |
|
ok to test |
|
Test build #82074 has finished for PR 19302 at commit
|
|
I am opening a new jira SPARK-22088 for this. I will close this PR. The style fails is because a new JIRA SPARK-22088 fixed a style issue after I submit my PR. I have included that JIRA in my new PR. |

What changes were proposed in this pull request?
This pr is a follow-up PR for this merged trim function pr: Support Trim characters in the string trim function.
I am adding examples in the
ExpressionDescriptionsession forstringTrimfunctionHow was this patch tested?
This is documentation pr, and it passed all sql testing locally.