答案 0 :(得分:1)
您无法从scala DataFrame
创建List[A]
。您首先需要创建RDD[A]
,然后将其转换为DataFrame
。您还需要SQLContext
:
val conf = new SparkConf()
.setMaster("local[*]")
.setAppName("test")
val sc = new SparkContext(conf)
val sqlContext = new SQLContext(sc)
import sqlContext.implicits._
val test = sc.parallelize(List(1,2,3,4)).toDF
答案 1 :(得分:0)
作为参考,这是带有spark sql的Spark 2.0样板文件的样子:
import org.apache.spark.sql.SparkSession
object Test {
def main(args: Array[String]) {
val spark = SparkSession.builder()
.master("local")
.appName("some name")
.getOrCreate()
import spark.sqlContext.implicits._
}
}