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


##########
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)
+    checkEvaluation(emptyStringWithPositionGreater, "", create_row(""))

Review Comment:
   There is a special case testing for the `nonNullExpr` so I followed that 
pattern instead of grouping with the other cases, since this is also a special 
case and wanted to keep it separate.
   I am happy to change it though, should I just add `row7` above with the 
other rows and the `checkEvaluation` bits together with the other 
`checkEvauation` bits then?



-- 
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