2017-06-15 60 views
0

我編寫了一個罐子在Spark上運行,我的項目包括廣口瓶是enter image description here星火SQL約rddToDataFrameHolder

和我的Hadoop的火花火花2.0.2彬hadoop2.7 當我運行我的罐子enter image description here 是版本衝突嗎? 後續是我的代碼

case class VehicleInfo(vin: String, vehicle_license: String, sales_id: String) 

對象ChangeStatus { DEF主(參數:數組[字符串]):單位= {

//txt path in hdfs 
val path = args(0) 

val sparkConf = new SparkConf().setAppName("change_status") 
val sc = new SparkContext(sparkConf) 
val sqlContext = new SQLContext(sc) 

import sqlContext.implicits._ 

val input = sc.textFile(path) 
    .map(line => line.split("\\|")) 
    .map(line => VehicleInfo(line(0), line(1), line(2))) 
    .toDF() 

input.registerTempTable("vehicle_info") 

val result_df = sqlContext.sql("select * from vehicle_info limit 10") 

result_df.show() 

} }

什麼是有關該問題的我的碼?

回答

0

問題很可能是您針對Spark 2.0.2運行,但是針對Spark 1.5.1進行編譯。通常,Spark對兼容性非常好 - 即使在二進制級別。然而,這個跨越主要版本,並且必然會發生重大變化。所以,我會說只是編譯2.0.2