cloud-fan commented on a change in pull request #27508: [SPARK-30763][SQL] Fix 
java.lang.IndexOutOfBoundsException No group 1 for regexp_extract
URL: https://github.com/apache/spark/pull/27508#discussion_r377052956
 
 

 ##########
 File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/RegexpExpressionsSuite.scala
 ##########
 @@ -293,6 +293,27 @@ class RegexpExpressionsSuite extends SparkFunSuite with 
ExpressionEvalHelper {
 
     val nonNullExpr = RegExpExtract(Literal("100-200"), 
Literal("(\\d+)-(\\d+)"), Literal(1))
     checkEvaluation(nonNullExpr, "100", row1)
+
+    // invalid group index
+    val row8 = create_row("100-200", "(\\d+)-(\\d+)", 3)
+    val row9 = create_row("100-200", "(\\d+).*", 2)
+    val row10 = create_row("100-200", "\\d+", 1)
+
+    val invalidGroupIndex1 = intercept[AnalysisException] {
+      evaluateWithoutCodegen(expr, row8)
 
 Review comment:
   As UT we should test both codegen and non-codegen, let's call 
`checkExceptionInExpression`

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to