You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/12/10 17:59:21 UTC

[GitHub] [spark] MaxGekk commented on a change in pull request #30711: [SPARK-33742][SQL] Throw PartitionsAlreadyExistException from HiveExternalCatalog.createPartitions()

MaxGekk commented on a change in pull request #30711:
URL: https://github.com/apache/spark/pull/30711#discussion_r540380914



##########
File path: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala
##########
@@ -981,6 +982,19 @@ private[spark] class HiveExternalCatalog(conf: SparkConf, hadoopConf: Configurat
     spec.map { case (k, v) => partCols.find(_.equalsIgnoreCase(k)).get -> v }
   }
 
+  private def isAlreadyExistsException(e: Throwable): Boolean = {
+    val maxDepth = 4
+    var depth = 0
+    var cause = e
+    var found = false
+    while (!found && depth < maxDepth && cause != null) {
+      found = cause.getClass.getCanonicalName == classOf[AlreadyExistsException].getCanonicalName

Review comment:
       I had to compare exceptions by their names because pattern matching and `isInstanceOf` don't work as we could expect. See the comment: https://github.com/apache/spark/blob/781e19c4d1f376b52e5305078356bf0a58522bcd/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala#L83-L84 




----------------------------------------------------------------
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:
users@infra.apache.org



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