How to convert a case-class-based RDD into a DataFrame?

后端 未结 3 1630
暗喜
暗喜 2021-01-04 08:33

The Spark documentation shows how to create a DataFrame from an RDD, using Scala case classes to infer a schema. I am trying to reproduce this concept using sqlContext

3条回答
  •  轮回少年
    2021-01-04 08:50

    You can create a DataFrame directly from a Seq of case class instances using toDF as follows:

    val dogDf = Seq(Dog("Rex"), Dog("Fido")).toDF
    

提交回复
热议问题