You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "heyihong (via GitHub)" <gi...@apache.org> on 2023/08/16 13:54:33 UTC

[GitHub] [spark] heyihong commented on a diff in pull request #42471: [SPARK-44785][SQL][CONNECT] Convert common alreadyExistsExceptions and noSuchExceptions

heyihong commented on code in PR #42471:
URL: https://github.com/apache/spark/pull/42471#discussion_r1295956355


##########
connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/connect/client/GrpcExceptionConverter.scala:
##########
@@ -62,14 +63,20 @@ private[client] object GrpcExceptionConverter extends JsonUtils {
   }
 
   private def errorConstructor[T <: Throwable: ClassTag](
-      throwableCtr: (String, Throwable) => T): (String, (String, Throwable) => Throwable) = {
+      throwableCtr: (String, Option[Throwable]) => T)
+      : (String, (String, Option[Throwable]) => Throwable) = {
     val className = implicitly[reflect.ClassTag[T]].runtimeClass.getName
     (className, throwableCtr)
   }
 
   private val errorFactory = Map(
     errorConstructor((message, _) => new ParseException(None, message, Origin(), Origin())),
-    errorConstructor((message, cause) => new AnalysisException(message, cause = Option(cause))))
+    errorConstructor((message, cause) => new AnalysisException(message, cause = cause)),
+    errorConstructor((message, _) => new NamespaceAlreadyExistsException(message)),

Review Comment:
   Yes, the current idea is to convert the common exceptions for better compatibility with the existing control flow that catch exceptions from spark sql.  



##########
connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/connect/client/GrpcExceptionConverter.scala:
##########
@@ -62,14 +63,20 @@ private[client] object GrpcExceptionConverter extends JsonUtils {
   }
 
   private def errorConstructor[T <: Throwable: ClassTag](
-      throwableCtr: (String, Throwable) => T): (String, (String, Throwable) => Throwable) = {
+      throwableCtr: (String, Option[Throwable]) => T)
+      : (String, (String, Option[Throwable]) => Throwable) = {
     val className = implicitly[reflect.ClassTag[T]].runtimeClass.getName
     (className, throwableCtr)
   }
 
   private val errorFactory = Map(
     errorConstructor((message, _) => new ParseException(None, message, Origin(), Origin())),
-    errorConstructor((message, cause) => new AnalysisException(message, cause = Option(cause))))
+    errorConstructor((message, cause) => new AnalysisException(message, cause = cause)),
+    errorConstructor((message, _) => new NamespaceAlreadyExistsException(message)),

Review Comment:
   Yes, the current idea is to convert the common exceptions for better compatibility with the existing control flows that catch exceptions from spark sql.  



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