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


##########
sql/api/src/main/scala/org/apache/spark/sql/AnalysisException.scala:
##########
@@ -139,18 +139,15 @@ class AnalysisException protected (
       cause = cause)
 
   def this(
-      message: String,
-      cause: Option[Throwable],
-      errorClass: Option[String],
+      errorClass: String,
       messageParameters: Map[String, String],
       context: Array[QueryContext],
+      cause: Option[Throwable],
       sqlState: Option[String]) =
     this(
-      message = message,
-      line = None,
-      startPosition = None,
+      message = SparkThrowableHelper.getMessage(errorClass, messageParameters),
       cause = cause,
-      errorClass = errorClass,
+      errorClass = Option(errorClass),

Review Comment:
   Based on the code, this constructor is only used in 
GrpcExceptionConverter.scala (BTW, we should limit the visibility of this 
constructor by using private[sql]), if I understand correctly. A null value for 
errorClass is invalid input (On the other hand, other parameters can also be 
null), so it should fail early instead of being converted to None. We can add 
assert(errorClass != null) for safety.
   
   Also, `SparkThrowableHelper.getMessage(errorClass, messageParameters)` will 
fail if errorClass is null.



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

Reply via email to