值拆分不是(String,String,String,String,String)的成员

时间:2017-03-29 06:47:03

标签: scala apache-spark apache-spark-sql spark-dataframe

通过连接两个表来给出数据。

joinDataRdd.take(5).foreach(println)
(41234,((102921,249,2,109.94,54.97),(2014-04-04 00:00:00.0,3182,PENDING_PAYMENT)))
(65722,((164249,365,2,119.98,59.99),(2014-05-23 00:00:00.0,4077,COMPLETE)))
(65722,((164250,730,5,400.0,80.0),(2014-05-23 00:00:00.0,4077,COMPLETE)))
(65722,((164251,1004,1,399.98,399.98),(2014-05-23 00:00:00.0,4077,COMPLETE)))
(65722,((164252,627,5,199.95,39.99),(2014-05-23 00:00:00.0,4077,COMPLETE)))

当我想要跟随时  val data = joinDataRdd.map(x =>(x._1,x._2._1.split(",")(3)))

它正在抛出一个错误: value split不是(String,String,String,String,String)

的成员

2 个答案:

答案 0 :(得分:1)

val data = joinDataRdd.map(x=>(x._1,x._2._1._1.split(",")(3)))

您正在尝试拆分元组,这就是错误消息的原因。在给定位置x._2._1, (41234,((102921,249,2,109.94,54.97),(2014-04-04 00:00:00.0,3182,PENDING_PAYMENT))),突出显示的数据是结果。因此,如果您想要挖掘元组内部,那么您需要前进一个位置。

答案 1 :(得分:0)

看起来这些值已经存在于元组中,因此您无需拆分字符串。是

val data = joinDataRdd.map(x=>(x._1,x._2._1._4))

你在找什么?