通常我需要输入两个非常接近的列的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>