且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

toDF的值不是org.apache.spark.rdd.RDD [(Long,org.apache.spark.ml.linalg.Vector)]的成员

更新时间:2023-11-18 22:47:58

需要完成2件事:

导入隐式:请注意,只有在创建 org.apache.spark.sql.SQLContext 的实例之后,才应执行此操作.它应写为:

Import implicits: Note that this should be done only after an instance of org.apache.spark.sql.SQLContext is created. It should be written as:

val sqlContext= new org.apache.spark.sql.SQLContext(sc)

import sqlContext.implicits._

将案例类移到方法之外:通过案例类,您可以使用它定义DataFrame的架构,应在需要它的方法之外定义.您可以在此处了解更多信息: https://issues.scala-lang.org/浏览/SI-6649

Move case class outside of the method: case class, by use of which you define the schema of the DataFrame, should be defined outside of the method needing it. You can read more about it here: https://issues.scala-lang.org/browse/SI-6649