Skip to content

Commit fafa8d8

Browse files
committed
[SPARK-25202][SQL][FOLLOW-UP] Keep the old parameter name 'pattern' at split in Scala API
### What changes were proposed in this pull request? To address the concern pointed out in #22227. This will make `split` source-compatible by removing minimal cosmetic changes. ### Why are the changes needed? For source compatibility. ### Does this PR introduce any user-facing change? No (it will prevent potential user-facing change from the original PR) ### How was this patch tested? Unittest was changed (in order for us to detect that source compatibility easily). Closes #27756 from HyukjinKwon/SPARK-25202. Authored-by: HyukjinKwon <gurwls223@apache.org> Signed-off-by: HyukjinKwon <gurwls223@apache.org> (cherry picked from commit 3956e95) Signed-off-by: HyukjinKwon <gurwls223@apache.org>
1 parent 597bbbb commit fafa8d8

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

sql/core/src/main/scala/org/apache/spark/sql/functions.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,25 +2460,25 @@ object functions {
24602460
def soundex(e: Column): Column = withExpr { SoundEx(e.expr) }
24612461

24622462
/**
2463-
* Splits str around matches of the given regex.
2463+
* Splits str around matches of the given pattern.
24642464
*
24652465
* @param str a string expression to split
2466-
* @param regex a string representing a regular expression. The regex string should be
2467-
* a Java regular expression.
2466+
* @param pattern a string representing a regular expression. The regex string should be
2467+
* a Java regular expression.
24682468
*
24692469
* @group string_funcs
24702470
* @since 1.5.0
24712471
*/
2472-
def split(str: Column, regex: String): Column = withExpr {
2473-
StringSplit(str.expr, Literal(regex), Literal(-1))
2472+
def split(str: Column, pattern: String): Column = withExpr {
2473+
StringSplit(str.expr, Literal(pattern), Literal(-1))
24742474
}
24752475

24762476
/**
2477-
* Splits str around matches of the given regex.
2477+
* Splits str around matches of the given pattern.
24782478
*
24792479
* @param str a string expression to split
2480-
* @param regex a string representing a regular expression. The regex string should be
2481-
* a Java regular expression.
2480+
* @param pattern a string representing a regular expression. The regex string should be
2481+
* a Java regular expression.
24822482
* @param limit an integer expression which controls the number of times the regex is applied.
24832483
* <ul>
24842484
* <li>limit greater than 0: The resulting array's length will not be more than limit,
@@ -2491,8 +2491,8 @@ object functions {
24912491
* @group string_funcs
24922492
* @since 3.0.0
24932493
*/
2494-
def split(str: Column, regex: String, limit: Int): Column = withExpr {
2495-
StringSplit(str.expr, Literal(regex), Literal(limit))
2494+
def split(str: Column, pattern: String, limit: Int): Column = withExpr {
2495+
StringSplit(str.expr, Literal(pattern), Literal(limit))
24962496
}
24972497

24982498
/**

sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class DataFrameSuite extends QueryTest
196196
test("explode on output of array-valued function") {
197197
val df = Seq(("1,2"), ("4"), ("7,8,9")).toDF("csv")
198198
checkAnswer(
199-
df.select(explode(split($"csv", ","))),
199+
df.select(explode(split($"csv", pattern = ","))),
200200
Row("1") :: Row("2") :: Row("4") :: Row("7") :: Row("8") :: Row("9") :: Nil)
201201
}
202202

0 commit comments

Comments
 (0)