doric icon indicating copy to clipboard operation
doric copied to clipboard

Custom types within product types

Open jserranohidalgo opened this issue 2 years ago • 0 comments

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.

jserranohidalgo avatar Jul 14 '22 14:07 jserranohidalgo