0
我想實現這樣的爲什麼會出現空指針異常
Object Main extends app {
val sc = new SparkContext(sparkConf)
val hiveContext = new org.apache.spark.sql.hive.HiveContext(sc)
val data = hiveContext.sql("select * from person").map(mapData(_))
println(data.collect())
def mapData(row:Row){
val data = new Person <- Java object
data.setName(getStringTrimmedToNull(row.getAs("name")))
data.setId(getStringTrimmedToNull(row.getAs("id")))
var salaryQuery = "select * from salary where id = '${id}'"
val query = salaryQuery. replace("${id}",data.getId)
hiveContext.sql(query).map(mapSalData(_))
}
def mapSalData(row:Row){
val salData = new Salary <= object for java class salary
//set data into the object
}
}
以上是我想要做的僞代碼,它是在該行返回空指針錯誤
hiveContext.sql(query).map(mapSalData(_))
有沒有人有任何想法我做錯了什麼?
你能用英文描述你想做什麼嗎? – Aaron