相关疑难解决方法(0)

值toDF不是org.apache.spark.rdd.RDD的成员

例外:

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)

sbt apache-spark-sql

20
推荐指数
3
解决办法
3万
查看次数

标签 统计

apache-spark-sql ×1

sbt ×1