Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Intellij idea 为什么可以';不知道如何找到toDS()和toDF()函数?_Intellij Idea_Apache Spark Sql - Fatal编程技术网

Intellij idea 为什么可以';不知道如何找到toDS()和toDF()函数?

Intellij idea 为什么可以';不知道如何找到toDS()和toDF()函数?,intellij-idea,apache-spark-sql,Intellij Idea,Apache Spark Sql,我的代码在spark shell中运行良好: scala> case class Person(name:String,age:Int) defined class Person scala> val person = Seq(Person("ppopo",23)).toDS() person: org.apache.spark.sql.Dataset[Person] = [name: string, age: int] scala> person.show() +----

我的代码在spark shell中运行良好:

scala> case class Person(name:String,age:Int)
defined class Person

scala> val person = Seq(Person("ppopo",23)).toDS()
person: org.apache.spark.sql.Dataset[Person] = [name: string, age: int]

scala> person.show()
+-----+---+
| name|age|
+-----+---+
|ppopo| 23|
+-----+---+
但这个想法是错误的:



我已导入“spark-2.0.0-bin-hadoop2.7/jars/”中的所有JAR,但仍然找不到此函数。

我发现问题,请在使用toDS()之前添加依赖项:

val ss = SparkSession.builder().appName("DataSet Test")
  .master("local[*]").getOrCreate()

// This import is needed
import ss.implicits._
val simpleDS = Seq(Person("po",12)).toDS()
simpleDS.show()