我正在尝试执行以下代码但收到此错误:
value toDF is not a member of Seq[(Int,String)].
我在 main 之外有 case 类,我也导入implicits了。但我仍然收到此错误。有人可以帮我解决这个问题吗?我正在使用Spark 2.11-2.1.0和Scala 2.11.8
import org.apache.spark.sql._
import org.apache.spark.ml.clustering._
import org.apache.spark.ml.feature.VectorAssembler
import org.apache.spark._
final case class Email(id: Int, text: String)
object SampleKMeans {
def main(args: Array[String]) = {
val spark = SparkSession.builder.appName("SampleKMeans")
.master("yarn")
.getOrCreate()
import spark.implicits._
val emails = Seq(
"This is an email from...",
"SPAM SPAM spam",
"Hello, We'd like to offer you")
.zipWithIndex.map(_.swap).toDF("id", "text").as[Email]
}
}
Run Code Online (Sandbox Code Playgroud)