Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom types within product types #250

Open
jserranohidalgo opened this issue Jul 14, 2022 · 0 comments
Open

Custom types within product types #250

jserranohidalgo opened this issue Jul 14, 2022 · 0 comments
Labels

Comments

@jserranohidalgo
Copy link
Member

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.

This was referenced Jul 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant