MaxGekk commented on code in PR #48379:
URL: https://github.com/apache/spark/pull/48379#discussion_r1804467411
##########
sql/core/src/test/scala/org/apache/spark/sql/CollationSQLRegexpSuite.scala:
##########
@@ -96,6 +98,36 @@ class CollationSQLRegexpSuite
}
}
+ test("RegExpReplace throws the right exception when replace fails on a
particular row") {
+ val tableName = "regexpReplaceException"
+ withTable(tableName) {
+ Seq("NO_CODEGEN", "CODEGEN_ONLY").foreach { codegenMode =>
+ withSQLConf("spark.sql.codegen.factoryMode" -> codegenMode) {
+ sql(s"CREATE TABLE IF NOT EXISTS $tableName(s STRING)")
+ sql(s"INSERT INTO $tableName VALUES('first last')")
Review Comment:
You don't need to create the table in the loop. Please, move to the upper
level.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/regexpExpressions.scala:
##########
@@ -700,7 +700,13 @@ case class RegExpReplace(subject: Expression, regexp:
Expression, rep: Expressio
m.region(position, source.length)
result.delete(0, result.length())
while (m.find) {
- m.appendReplacement(result, lastReplacement)
+ try {
+ m.appendReplacement(result, lastReplacement)
+ } catch {
+ case e: Exception =>
Review Comment:
at least catch non-fatal exceptions like:
```suggestion
case NonFatal(e) =>
```
##########
sql/core/src/test/scala/org/apache/spark/sql/CollationSQLRegexpSuite.scala:
##########
@@ -96,6 +98,36 @@ class CollationSQLRegexpSuite
}
}
+ test("RegExpReplace throws the right exception when replace fails on a
particular row") {
Review Comment:
Why did you place this test to collation related test suite, I wonder.
##########
sql/core/src/test/scala/org/apache/spark/sql/CollationSQLRegexpSuite.scala:
##########
@@ -96,6 +98,36 @@ class CollationSQLRegexpSuite
}
}
+ test("RegExpReplace throws the right exception when replace fails on a
particular row") {
+ val tableName = "regexpReplaceException"
+ withTable(tableName) {
+ Seq("NO_CODEGEN", "CODEGEN_ONLY").foreach { codegenMode =>
+ withSQLConf("spark.sql.codegen.factoryMode" -> codegenMode) {
Review Comment:
```suggestion
withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> codegenMode) {
```
--
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]