Skip to content

Commit 4e42f8b

Browse files
committed
[SPARK-39677][SQL][DOCS] Fix args formatting of the regexp and like functions
### What changes were proposed in this pull request? In the PR, I propose to fix args formatting of some regexp functions by adding explicit new lines. That fixes the following items in arg lists. Before: <img width="745" alt="Screenshot 2022-07-05 at 09 48 28" src="https://user-images.githubusercontent.com/1580697/177274234-04209d43-a542-4c71-b5ca-6f3239208015.png"> After: <img width="704" alt="Screenshot 2022-07-05 at 11 06 13" src="https://user-images.githubusercontent.com/1580697/177280718-cb05184c-8559-4461-b94d-dfaaafda7dd2.png"> ### Why are the changes needed? To improve readability of Spark SQL docs. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? By building docs and checking manually: ``` $ SKIP_SCALADOC=1 SKIP_PYTHONDOC=1 SKIP_RDOC=1 bundle exec jekyll build ``` Closes #37082 from MaxGekk/fix-regexp-docs. Authored-by: Max Gekk <[email protected]> Signed-off-by: Max Gekk <[email protected]>
1 parent 161c596 commit 4e42f8b

File tree

1 file changed

+16
-30
lines changed

1 file changed

+16
-30
lines changed

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

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,12 @@ abstract class StringRegexExpression extends BinaryExpression
8484
Arguments:
8585
* str - a string expression
8686
* pattern - a string expression. The pattern is a string which is matched literally, with
87-
exception to the following special symbols:
88-
89-
_ matches any one character in the input (similar to . in posix regular expressions)
90-
87+
exception to the following special symbols:<br><br>
88+
_ matches any one character in the input (similar to . in posix regular expressions)\
9189
% matches zero or more characters in the input (similar to .* in posix regular
92-
expressions)
93-
90+
expressions)<br><br>
9491
Since Spark 2.0, string literals are unescaped in our SQL parser. For example, in order
95-
to match "\abc", the pattern should be "\\abc".
96-
92+
to match "\abc", the pattern should be "\\abc".<br><br>
9793
When SQL config 'spark.sql.parser.escapedStringLiterals' is enabled, it falls back
9894
to Spark 1.6 behavior regarding string literal parsing. For example, if the config is
9995
enabled, the pattern to match "\abc" should be "\abc".
@@ -189,7 +185,7 @@ case class Like(left: Expression, right: Expression, escapeChar: Char)
189185
copy(left = newLeft, right = newRight)
190186
}
191187

192-
// scalastyle:off line.contains.tab
188+
// scalastyle:off line.contains.tab line.size.limit
193189
/**
194190
* Simple RegEx case-insensitive pattern matching function
195191
*/
@@ -200,16 +196,12 @@ case class Like(left: Expression, right: Expression, escapeChar: Char)
200196
Arguments:
201197
* str - a string expression
202198
* pattern - a string expression. The pattern is a string which is matched literally and
203-
case-insensitively, with exception to the following special symbols:
204-
205-
_ matches any one character in the input (similar to . in posix regular expressions)
206-
199+
case-insensitively, with exception to the following special symbols:<br><br>
200+
_ matches any one character in the input (similar to . in posix regular expressions)<br><br>
207201
% matches zero or more characters in the input (similar to .* in posix regular
208-
expressions)
209-
202+
expressions)<br><br>
210203
Since Spark 2.0, string literals are unescaped in our SQL parser. For example, in order
211-
to match "\abc", the pattern should be "\\abc".
212-
204+
to match "\abc", the pattern should be "\\abc".<br><br>
213205
When SQL config 'spark.sql.parser.escapedStringLiterals' is enabled, it falls back
214206
to Spark 1.6 behavior regarding string literal parsing. For example, if the config is
215207
enabled, the pattern to match "\abc" should be "\abc".
@@ -237,7 +229,7 @@ case class Like(left: Expression, right: Expression, escapeChar: Char)
237229
""",
238230
since = "3.3.0",
239231
group = "predicate_funcs")
240-
// scalastyle:on line.contains.tab
232+
// scalastyle:on line.contains.tab line.size.limit
241233
case class ILike(
242234
left: Expression,
243235
right: Expression,
@@ -574,12 +566,10 @@ case class StringSplit(str: Expression, regex: Expression, limit: Expression)
574566
Arguments:
575567
* str - a string expression to search for a regular expression pattern match.
576568
* regexp - a string representing a regular expression. The regex string should be a
577-
Java regular expression.
578-
569+
Java regular expression.<br><br>
579570
Since Spark 2.0, string literals (including regex patterns) are unescaped in our SQL
580571
parser. For example, to match "\abc", a regular expression for `regexp` can be
581-
"^\\abc$".
582-
572+
"^\\abc$".<br><br>
583573
There is a SQL config 'spark.sql.parser.escapedStringLiterals' that can be used to
584574
fallback to the Spark 1.6 behavior regarding string literal parsing. For example,
585575
if the config is enabled, the `regexp` that can match "\abc" is "^\abc$".
@@ -783,12 +773,10 @@ abstract class RegExpExtractBase
783773
Arguments:
784774
* str - a string expression.
785775
* regexp - a string representing a regular expression. The regex string should be a
786-
Java regular expression.
787-
776+
Java regular expression.<br><br>
788777
Since Spark 2.0, string literals (including regex patterns) are unescaped in our SQL
789778
parser. For example, to match "\abc", a regular expression for `regexp` can be
790-
"^\\abc$".
791-
779+
"^\\abc$".<br><br>
792780
There is a SQL config 'spark.sql.parser.escapedStringLiterals' that can be used to
793781
fallback to the Spark 1.6 behavior regarding string literal parsing. For example,
794782
if the config is enabled, the `regexp` that can match "\abc" is "^\abc$".
@@ -888,12 +876,10 @@ case class RegExpExtract(subject: Expression, regexp: Expression, idx: Expressio
888876
Arguments:
889877
* str - a string expression.
890878
* regexp - a string representing a regular expression. The regex string should be a
891-
Java regular expression.
892-
879+
Java regular expression.<br><br>
893880
Since Spark 2.0, string literals (including regex patterns) are unescaped in our SQL
894881
parser. For example, to match "\abc", a regular expression for `regexp` can be
895-
"^\\abc$".
896-
882+
"^\\abc$".<br><br>
897883
There is a SQL config 'spark.sql.parser.escapedStringLiterals' that can be used to
898884
fallback to the Spark 1.6 behavior regarding string literal parsing. For example,
899885
if the config is enabled, the `regexp` that can match "\abc" is "^\abc$".

0 commit comments

Comments
 (0)