Skip to content

Commit 9cac249

Browse files
viiryagatorsmile
authored andcommitted
[SPARK-22088][SQL] Incorrect scalastyle comment causes wrong styles in stringExpressions
## What changes were proposed in this pull request? There is an incorrect `scalastyle:on` comment in `stringExpressions.scala` and causes the line size limit check ineffective in the file. There are many lines of code and comment which are more than 100 chars. ## How was this patch tested? Code style change only. Author: Liang-Chi Hsieh <[email protected]> Closes apache#19305 from viirya/fix-wrong-style.
1 parent f7ad0db commit 9cac249

File tree

1 file changed

+40
-28
lines changed

1 file changed

+40
-28
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ case class StringTranslate(srcExpr: Expression, matchingExpr: Expression, replac
484484
> SELECT _FUNC_('ab','abc,b,ab,c,def');
485485
3
486486
""")
487-
// scalastyle:on
487+
// scalastyle:on line.size.limit
488488
case class FindInSet(left: Expression, right: Expression) extends BinaryExpression
489489
with ImplicitCastInputTypes {
490490

@@ -519,16 +519,18 @@ object StringTrim {
519519
}
520520

521521
/**
522-
* A function that takes a character string, removes the leading and trailing characters matching with any character
523-
* in the trim string, returns the new string.
524-
* If BOTH and trimStr keywords are not specified, it defaults to remove space character from both ends. The trim
525-
* function will have one argument, which contains the source string.
526-
* If BOTH and trimStr keywords are specified, it trims the characters from both ends, and the trim function will have
527-
* two arguments, the first argument contains trimStr, the second argument contains the source string.
528-
* trimStr: A character string to be trimmed from the source string, if it has multiple characters, the function
529-
* searches for each character in the source string, removes the characters from the source string until it
530-
* encounters the first non-match character.
531-
* BOTH: removes any character from both ends of the source string that matches characters in the trim string.
522+
* A function that takes a character string, removes the leading and trailing characters matching
523+
* with any character in the trim string, returns the new string.
524+
* If BOTH and trimStr keywords are not specified, it defaults to remove space character from both
525+
* ends. The trim function will have one argument, which contains the source string.
526+
* If BOTH and trimStr keywords are specified, it trims the characters from both ends, and the trim
527+
* function will have two arguments, the first argument contains trimStr, the second argument
528+
* contains the source string.
529+
* trimStr: A character string to be trimmed from the source string, if it has multiple characters,
530+
* the function searches for each character in the source string, removes the characters from the
531+
* source string until it encounters the first non-match character.
532+
* BOTH: removes any character from both ends of the source string that matches characters in the
533+
* trim string.
532534
*/
533535
@ExpressionDescription(
534536
usage = """
@@ -612,19 +614,22 @@ case class StringTrim(
612614
}
613615

614616
object StringTrimLeft {
615-
def apply(str: Expression, trimStr: Expression) : StringTrimLeft = StringTrimLeft(str, Some(trimStr))
616-
def apply(str: Expression) : StringTrimLeft = StringTrimLeft(str, None)
617+
def apply(str: Expression, trimStr: Expression): StringTrimLeft =
618+
StringTrimLeft(str, Some(trimStr))
619+
def apply(str: Expression): StringTrimLeft = StringTrimLeft(str, None)
617620
}
618621

619622
/**
620623
* A function that trims the characters from left end for a given string.
621-
* If LEADING and trimStr keywords are not specified, it defaults to remove space character from the left end. The ltrim
622-
* function will have one argument, which contains the source string.
623-
* If LEADING and trimStr keywords are not specified, it trims the characters from left end. The ltrim function will
624-
* have two arguments, the first argument contains trimStr, the second argument contains the source string.
625-
* trimStr: the function removes any character from the left end of the source string which matches with the characters
626-
* from trimStr, it stops at the first non-match character.
627-
* LEADING: removes any character from the left end of the source string that matches characters in the trim string.
624+
* If LEADING and trimStr keywords are not specified, it defaults to remove space character from
625+
* the left end. The ltrim function will have one argument, which contains the source string.
626+
* If LEADING and trimStr keywords are not specified, it trims the characters from left end. The
627+
* ltrim function will have two arguments, the first argument contains trimStr, the second argument
628+
* contains the source string.
629+
* trimStr: the function removes any character from the left end of the source string which matches
630+
* with the characters from trimStr, it stops at the first non-match character.
631+
* LEADING: removes any character from the left end of the source string that matches characters in
632+
* the trim string.
628633
*/
629634
@ExpressionDescription(
630635
usage = """
@@ -709,20 +714,24 @@ case class StringTrimLeft(
709714
}
710715

711716
object StringTrimRight {
712-
def apply(str: Expression, trimStr: Expression) : StringTrimRight = StringTrimRight(str, Some(trimStr))
717+
def apply(str: Expression, trimStr: Expression): StringTrimRight =
718+
StringTrimRight(str, Some(trimStr))
713719
def apply(str: Expression) : StringTrimRight = StringTrimRight(str, None)
714720
}
715721

716722
/**
717723
* A function that trims the characters from right end for a given string.
718-
* If TRAILING and trimStr keywords are not specified, it defaults to remove space character from the right end. The
719-
* rtrim function will have one argument, which contains the source string.
720-
* If TRAILING and trimStr keywords are specified, it trims the characters from right end. The rtrim function will
721-
* have two arguments, the first argument contains trimStr, the second argument contains the source string.
722-
* trimStr: the function removes any character from the right end of source string which matches with the characters
723-
* from trimStr, it stops at the first non-match character.
724-
* TRAILING: removes any character from the right end of the source string that matches characters in the trim string.
724+
* If TRAILING and trimStr keywords are not specified, it defaults to remove space character
725+
* from the right end. The rtrim function will have one argument, which contains the source string.
726+
* If TRAILING and trimStr keywords are specified, it trims the characters from right end. The
727+
* rtrim function will have two arguments, the first argument contains trimStr, the second argument
728+
* contains the source string.
729+
* trimStr: the function removes any character from the right end of source string which matches
730+
* with the characters from trimStr, it stops at the first non-match character.
731+
* TRAILING: removes any character from the right end of the source string that matches characters
732+
* in the trim string.
725733
*/
734+
// scalastyle:off line.size.limit
726735
@ExpressionDescription(
727736
usage = """
728737
_FUNC_(str) - Removes the trailing space characters from `str`.
@@ -741,6 +750,7 @@ object StringTrimRight {
741750
> SELECT _FUNC_('LQSa', 'SSparkSQLS');
742751
SSpark
743752
""")
753+
// scalastyle:on line.size.limit
744754
case class StringTrimRight(
745755
srcStr: Expression,
746756
trimStr: Option[Expression] = None)
@@ -812,13 +822,15 @@ case class StringTrimRight(
812822
*
813823
* NOTE: that this is not zero based, but 1-based index. The first character in str has index 1.
814824
*/
825+
// scalastyle:off line.size.limit
815826
@ExpressionDescription(
816827
usage = "_FUNC_(str, substr) - Returns the (1-based) index of the first occurrence of `substr` in `str`.",
817828
examples = """
818829
Examples:
819830
> SELECT _FUNC_('SparkSQL', 'SQL');
820831
6
821832
""")
833+
// scalastyle:on line.size.limit
822834
case class StringInstr(str: Expression, substr: Expression)
823835
extends BinaryExpression with ImplicitCastInputTypes {
824836

0 commit comments

Comments
 (0)