我正在尝试使用Spark中的数据集,正在加载文件并使用案例类作为模式头,但是它不起作用。但是它没有案例类和数据集就可以工作。
case class musicTable(userid:String,songid:String,artistid:String,date:String,start_ts:String,end_ts:String,geocd:String,stationid:String,song_end_type:Long,like:Long,dislike:Long)
val Mobpath1 = spark.read.csv("/home/musicdata/mob.txt").as[musicTable]
Mobpath1.show()
对于上述代码,其显示错误为
Exception in thread "main" org.apache.spark.sql.AnalysisException: cannot resolve '`userid`' given input columns: [_c3, _c1, _c8, _c6, _c9, _c2, _c10, _c0, _c4, _c7, _c5];
at org.apache.spark.sql.catalyst.analysis.package$AnalysisErrorAt.failAnalysis(package.scala:42)
at org.apache.spark.sql.catalyst.analysis.CheckAnalysis$$anonfun$checkAnalysis$1$$anonfun$apply$2.applyOrElse(CheckAnalysis.scala:88)