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

Field access for custom product types #249

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

Field access for custom product types #249

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

Comments

@jserranohidalgo
Copy link
Member

jserranohidalgo commented Jul 14, 2022

For instance, given the following custom product 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}")
}

we would like to access fields of users as follows:

col[User]("user").field("name"): DoricColumn[String]
col[User]("user").field("age"): DoricColumn[Int]

That is, even if the User product type is internally represented as a String, doric must offer programmers the API of product types for manipulating User columns.

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