MaxGekk commented on code in PR #57228:
URL: https://github.com/apache/spark/pull/57228#discussion_r3576792183
##########
sql/api/src/main/scala/org/apache/spark/sql/types/DataType.scala:
##########
@@ -345,7 +345,15 @@ object DataType {
}
// Defense in depth: resolve the class without initializing it and
verify that it really is a
// UserDefinedType subclass before constructing it.
- val clazz = SparkClassUtils.classForName[UserDefinedType[_]](udtClass,
initialize = false)
+ val clazz = try {
+ SparkClassUtils.classForName[UserDefinedType[_]](udtClass, initialize
= false)
+ } catch {
+ case e: ClassNotFoundException =>
+ throw new SparkClassNotFoundException(
+ errorClass = "UDT_CLASS_NOT_FOUND.WITHOUT_USER_CLASS",
+ messageParameters = Map("udtClass" -> udtClass),
+ cause = e)
+ }
Review Comment:
The Scala linter CI check (`Linters, licenses, and dependencies`) is failing
on scalafmt here — `Scalafmt: Unformatted files found` in the `spark-sql-api`
module. scalafmt wants the `try` on its own line under the assignment (and the
body re-indented). Applying:
```suggestion
val clazz =
try {
SparkClassUtils.classForName[UserDefinedType[_]](udtClass,
initialize = false)
} catch {
case e: ClassNotFoundException =>
throw new SparkClassNotFoundException(
errorClass = "UDT_CLASS_NOT_FOUND.WITHOUT_USER_CLASS",
messageParameters = Map("udtClass" -> udtClass),
cause = e)
}
```
(Or just run `./dev/scalafmt`.)
--
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]