val sqlContext = new org.apache.spark.sql.SQLContext(sc)
import sqlContext.implicits._
case class Person(name:String,sex:String,age:Int)
var rdd3=rdd2.map(x=>Person(x(0),x(1),x(2).toInt))
var rdd4=rdd3.toDF
var rdd5=rdd4.map(row=>{var schemas=row.schema.fieldNames;var rs="";for(i<-schemas;if i=="sex"){rs=row.getString(1)};rs})
网友评论