sparksql Seq生成DataFrame
首先,使用样例类:
case class User(id:Int,name: String,gender:String, age: Int)
之后使用Seq创建Dataframe
val alice: User = User(3, "Alice", "F", 26) val tom: User = User(4, "Tom", "M", 23) val df: DataFrame = spark.createDataFrame(Seq(alice, tom))