ulysses-you commented on a change in pull request #29403:
URL: https://github.com/apache/spark/pull/29403#discussion_r496363878
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala
##########
@@ -377,6 +378,29 @@ object ScalaReflection extends ScalaReflection {
expressions.Literal.create(null, ObjectType(cls)),
newInstance
)
+
+ case t if isSubtype(t, localTypeOf[Enumeration#Value]) =>
+ // package example
+ // object Foo extends Enumeration {
+ // type Foo = Value
+ // val E1, E2 = Value
+ // }
+ // the fullName of tpe is example.Foo.Foo, but we need example.Foo so
that
+ // we can call example.Foo.withName to deserialize string to
enumeration.
+ val className = t.asInstanceOf[TypeRef].pre.typeSymbol.asClass.fullName
+ // this check is for spark-shell which give a default package name
like '$line1.$read$$iw'
+ if (className.startsWith("$")) {
+ throw new UnsupportedOperationException(
+ s"Enumeration class required package name, but found $className")
+ }
+
+ val clazz = Utils.classForName(className)
Review comment:
Let me check this again.
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]