例外:
val people = sc.textFile("resources/people.txt").map(_.split(",")).map(p => Person(p(0), p(1).trim.toInt)).toDF()
value toDF is not a member of org.apache.spark.rdd.RDD[Person]
Run Code Online (Sandbox Code Playgroud)
这是TestApp.scala文件:
package main.scala
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
import org.apache.spark.SparkConf
case class Record1(k: Int, v: String)
object RDDToDataFramesWithCaseClasses {
def main(args: Array[String]) {
val conf = new SparkConf().setAppName("Simple Spark SQL Application With RDD To DF")
// sc is an existing SparkContext.
val sc = new SparkContext(conf)
val sqlContext = new SQLContext(sc)
// this is used to implicitly convert an RDD to a DataFrame. …Run Code Online (Sandbox Code Playgroud) 我们面临一些问题,当我们尝试BigInteger在 Java 中使用BigIntsql进行映射时,它的值发生了变化。我们也尝试将其转换为longValue映射之前,但它也失败了,因为它无法处理它的值。我们尝试过toString(),它奏效了,但除了使用之外,他们还有其他解决方法toString()吗?