From 7ecbe4c28087564f1ba0adaa62a12cd28be351c0 Mon Sep 17 00:00:00 2001 From: Kevin Yu Date: Wed, 20 Sep 2017 14:35:57 -0700 Subject: [PATCH 1/3] adding examples for stringTrim string function --- .../expressions/stringExpressions.scala | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala index 6dfc59f58ad6d..e818ee2e84ffa 100755 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala @@ -535,20 +535,30 @@ object StringTrim { @ExpressionDescription( usage = """ _FUNC_(str) - Removes the leading and trailing space characters from `str`. - _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` """, arguments = """ Arguments: * str - a string expression - * trimString - the trim string - * BOTH, FROM - these are keyword to specify for trim string from both ends of the string + * trimStr - the trim string characters to trim, the default value is a single space + * BOTH, FROM - these are keywords to specify for trim string characters from both ends of the string + * LEADING, FROM - these are keywords to specify for trim string characters from left end of the string + * TRAILING, FROM - these are keywords to specify for trim string characters from right end of the string """, examples = """ Examples: > SELECT _FUNC_(' SparkSQL '); SparkSQL + > SELECT _FUNC_('SL', 'SSparkSQLS'); + parkSQ > SELECT _FUNC_(BOTH 'SL' FROM 'SSparkSQLS'); parkSQ + > SELECT _FUNC_(LEADING 'SL' FROM 'SSparkSQLS'); + parkSQLS + > SELECT _FUNC_(TRAILING 'SL' FROM 'SSparkSQLS'); + SSparkSQ """) case class StringTrim( srcStr: Expression, @@ -639,8 +649,7 @@ object StringTrimLeft { arguments = """ Arguments: * str - a string expression - * trimString - the trim string - * BOTH, FROM - these are keyword to specify for trim string from both ends of the string + * trimStr - the trim string characters to trim, the default value is a single space """, examples = """ Examples: @@ -740,8 +749,7 @@ object StringTrimRight { arguments = """ Arguments: * str - a string expression - * trimString - the trim string - * BOTH, FROM - these are keyword to specify for trim string from both ends of the string + * trimStr - the trim string characters to trim, the default value is a single space """, examples = """ Examples: From 4f77d95cbd2492db0d398612dd28a0a89ea849fd Mon Sep 17 00:00:00 2001 From: Kevin Yu Date: Wed, 20 Sep 2017 23:00:46 -0700 Subject: [PATCH 2/3] adjust comments --- .../sql/catalyst/expressions/stringExpressions.scala | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala index e818ee2e84ffa..1dc639f30266d 100755 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala @@ -535,17 +535,17 @@ object StringTrim { @ExpressionDescription( usage = """ _FUNC_(str) - Removes the leading and trailing space characters 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` + _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` """, arguments = """ 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 for trim string characters from both ends of the string - * LEADING, FROM - these are keywords to specify for trim string characters from left end of the string - * TRAILING, FROM - these are keywords to specify for trim string characters from right end of the string + * 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 = """ Examples: From 0f3307dfc3dd21b3d643d3d58e9202743f958b23 Mon Sep 17 00:00:00 2001 From: Kevin Yu Date: Fri, 22 Sep 2017 15:46:02 -0700 Subject: [PATCH 3/3] rebase --- .../catalyst/expressions/stringExpressions.scala | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala index 1dc639f30266d..c341943187820 100755 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala @@ -535,17 +535,23 @@ object StringTrim { @ExpressionDescription( usage = """ _FUNC_(str) - Removes the leading and trailing space characters 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` """, arguments = """ 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 + * 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 = """ Examples: @@ -644,6 +650,7 @@ object StringTrimLeft { @ExpressionDescription( usage = """ _FUNC_(str) - Removes the leading space characters from `str`. + _FUNC_(trimStr, str) - Removes the leading string contains the characters from the trim string """, arguments = """ @@ -744,6 +751,7 @@ object StringTrimRight { @ExpressionDescription( usage = """ _FUNC_(str) - Removes the trailing space characters from `str`. + _FUNC_(trimStr, str) - Removes the trailing string which contains the characters from the trim string from the `str` """, arguments = """