分享

sparkSQL问题

xw2016 发表于 2016-6-12 23:25:48 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 6 6960
在spark-shell中,执行如下代码:
val sqlContext=new org.apache.spark.sql.SQLContext(sc)
import sqlContext._


case class Person(name:String,age:Int)
val people=sc.textFile("hdfs://ns1/data/people.txt").map(_.split(",")).map(p=>Person(p(0),p(1).trim.toInt))
people.registerTempTable("people")

报错:
<console>:31: error: value registerTempTable is not a member of org.apache.spark.rdd.RDD[Person]
              people.registerTempTable("people")


我用的是spark1.5,这个版本不能这么用了吗?

已有(6)人评论

跳转到指定楼层
yuwenge 发表于 2016-6-13 08:04:40
楼主的标准的RDD(org.apache.spark.rdd.RDD)需转换成SchemaRDD
如何转换楼主参考
Spark:value registerTempTable is not a member of org.apache.spark.rdd.RDD解决
http://www.aboutyun.com/forum.php?mod=viewthread&tid=18823


回复

使用道具 举报

xw2016 发表于 2016-6-13 10:50:24
yuwenge 发表于 2016-6-13 08:04
楼主的标准的RDD(org.apache.spark.rdd.RDD)需转换成SchemaRDD
如何转换楼主参考
Spark:value registerTe ...

这个方法我昨天用过了,没成功,今天回去再看下吧。
回复

使用道具 举报

easthome001 发表于 2016-6-13 20:30:11
用过了是什么问题
回复

使用道具 举报

xw2016 发表于 2016-6-13 21:05:53
easthome001 发表于 2016-6-13 20:30
用过了是什么问题

scala> val peopleSchema = sqlContext.createSchemaRDD(people)
<console>:30: error: value createSchemaRDD is not a member of org.apache.spark.sql.SQLContext
       val peopleSchema = sqlContext.createSchemaRDD(people)

出现这个问题了

回复

使用道具 举报

liuzhixin137 发表于 2016-6-14 09:25:49

请问一下,怎么解决的,我的也跟你一模一样的问题,也是spark 1.5
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条