LorenzoMartini commented on code in PR #36457:
URL: https://github.com/apache/spark/pull/36457#discussion_r866723000


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/RegexpExpressionsSuite.scala:
##########
@@ -323,6 +323,16 @@ class RegexpExpressionsSuite extends SparkFunSuite with 
ExpressionEvalHelper {
     val nonNullExpr = RegExpReplace(Literal("100-200"), Literal("(\\d+)"), 
Literal("num"))
     checkEvaluation(nonNullExpr, "num-num", row1)
 
+    // Test empty string replacement
+    val emptyString = RegExpReplace(Literal(""), Literal("^$"), 
Literal("<empty string>"))
+    checkEvaluation(emptyString, "<empty string>", create_row("", "^$", 
"<empty string>"))
+    val emptyStringWithPositionOne =
+      RegExpReplace(Literal(""), Literal("^$"), Literal("<empty string>"), 1)
+    checkEvaluation(emptyStringWithPositionOne, "<empty string>", 
create_row(""))
+    val emptyStringWithPositionGreater =
+      RegExpReplace(Literal(""), Literal("^$"), Literal("<empty string>"), 2)

Review Comment:
   Maybe we actually want to special case this and throw if user gives us a 
regex replace with an empty string match but explicitly sets an expected 
position?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to