Github user mt40 commented on a diff in the pull request: https://github.com/apache/spark/pull/22309#discussion_r228741586 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala --- @@ -374,6 +383,29 @@ object ScalaReflection extends ScalaReflection { dataType = ObjectType(udt.getClass)) Invoke(obj, "deserialize", ObjectType(udt.userClass), path :: Nil) + case t if isValueClass(t) => + val (_, underlyingType) = getUnderlyingParameterOf(t) + val underlyingClsName = getClassNameFromType(underlyingType) + val clsName = getUnerasedClassNameFromType(t) + val newTypePath = s"""- Scala value class: $clsName($underlyingClsName)""" +: + walkedTypePath + + // Nested value class is treated as its underlying type + // because the compiler will convert value class in the schema to + // its underlying type. + // However, for value class that is top-level or array element, + // if it is used as another type (e.g. as its parent trait or generic), + // the compiler keeps the class so we must provide an instance of the + // class too. In other cases, the compiler will handle wrapping/unwrapping + // for us automatically. + val arg = deserializerFor(underlyingType, path, newTypePath) + if (walkedTypePath.length == 1 || walkedTypePath.head.contains("array element")) { --- End diff -- never mind, I think going with option 2 is better in the future
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org