From 3879e6df0a2df880632bebc9fdc4c0511e373e46 Mon Sep 17 00:00:00 2001 From: Kevin Yu Date: Wed, 20 Sep 2017 14:35:57 -0700 Subject: [PATCH 1/2] 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 83de515079ee..df6ead0b7f51 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 @@ -533,20 +533,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, @@ -634,8 +644,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: @@ -731,8 +740,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 795f41a60c612ead4ff42ab9283d5ad2af9b17e1 Mon Sep 17 00:00:00 2001 From: Kevin Yu Date: Wed, 20 Sep 2017 23:00:46 -0700 Subject: [PATCH 2/2] 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 df6ead0b7f51..af47c050f654 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 @@ -533,17 +533,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: