代码改变世界

value toDF is not a member of org.apache.spark.rdd.RDD

2017-10-23 23:03  轩脉刃  阅读(...)  评论(... 编辑 收藏

idea显示toDF() 没有这个函数,显示错误:

Error:(82, 8) value toDF is not a member of org.apache.spark.rdd.RDD[com.didichuxing.scala.BaseIndex]
possible cause: maybe a semicolon is missing before `value toDF'?
    }).toDF()

解决:
增加一行:

import sqlContext.implicits._

http://ifeve.com/spark-sql-dataframes/

在spark1.3,从RDD到DataFrame的隐式转换隔离出来,单独放到SQLContext.implicits对象中,所以现在需要把RDD转换为Dataframe就需要引入这个