You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "srowen (via GitHub)" <gi...@apache.org> on 2023/04/01 19:27:59 UTC

[GitHub] [spark] srowen commented on a diff in pull request #40588: [SPARK-42964][SQL] PosgresDialect '42P07' also means table already exists

srowen commented on code in PR #40588:
URL: https://github.com/apache/spark/pull/40588#discussion_r1155159586


##########
sql/core/src/main/scala/org/apache/spark/sql/jdbc/PostgresDialect.scala:
##########
@@ -217,10 +218,17 @@ private object PostgresDialect extends JdbcDialect with SQLConfHelper {
           case "42P07" =>
             // The message is: Failed to create index indexName in tableName
             val regex = "(?s)Failed to create index (.*) in (.*)".r
-            val indexName = regex.findFirstMatchIn(message).get.group(1)
-            val tableName = regex.findFirstMatchIn(message).get.group(2)
-            throw new IndexAlreadyExistsException(
-              indexName = indexName, tableName = tableName, cause = Some(e))
+            val maybeMatchIndex = regex.findFirstMatchIn(message)

Review Comment:
   Nit: you can use regexes in match expressions, it'd be a little cleaner. See end of https://docs.scala-lang.org/tour/regular-expression-patterns.html



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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