doric
doric copied to clipboard
Custom types within product types
Expected Behavior
Given a custom User
type:
case class User(name: String, age: Int)
object User {
implicit val userst: SparkType.Custom[User, String] =
SparkType[String].customType[User](x => {
val name :: age :: Nil = x.split("#").toList
User(name, age.toInt)
})
implicit val userlst: LiteralSparkType.Custom[User, String] =
LiteralSparkType[String].customType[User](x => s"${x.name}#${x.age}")
}
and a product type which contains the User
type:
case class Employee(user: User, home: String)
we should be able to deserialize values of this type from rows, and serialize literal values into spark columns.
Current Behavior (if so)
We can serialize/deserialize complex types which contains custom types: e.g. in arrays, seqs, maps and options. However, we can only deserialize case classes (like the previous Employee
) that contains custom types.
The missing feature is properly creating literal columns for Employee
-like values.