Spark数据集 - 避免重复Scala案例类字段

时间:2017-09-21 09:56:12

标签: scala apache-spark case-class

通常我需要输入两个非常接近的列的Spark数据集,如下所示:

case class Car (
  serial_number: Int,
  year: Int,
  brand: String,
  colour: String,
  horsepower: Int,
  weight: Int,
  width: Float,
  length: Float,
  seats: Int,
  owner: String,
  mileage: Int
)

case class CarWithOptionalMileage (
  serial_number: Int,
  year: Int,
  brand: String,
  colour: String,
  horsepower: Int,
  weight: Int,
  width: Float,
  length: Float,
  seats: Int,
  owner: String,
  mileage: Option[Int]        // <--- this is the only different field
)

我知道case class无法扩展另一个case class,但是有没有办法避免所有这些字段重复,只需指定CarWithOptionalMileage中的不同字段?< / p>

0 个答案:

没有答案