Skip to content

Field access for custom product types  #249

@jserranohidalgo

Description

@jserranohidalgo

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions