3,424
社区成员
发帖
与我相关
我的任务
分享
val conf = new SparkConf().setAppName("Test1").setMaster("local")
val sparkContext = new SparkContext(conf)
val context = new SQLContext(sparkContext)
val fieldSchema = StructType(Array(
StructField("area", StringType, true),
StructField("province", StringType, true),
StructField("type", StringType, true),
StructField("name", StringType, true),
StructField("year", StringType, true),
StructField("quarter", StringType, true),
StructField("big", StringType, true),
StructField("pname", StringType, true),
StructField("price", DoubleType, true)
))
val taxiDF = context.read.format("com.databricks.spark.csv")
.option("header", "false")
.schema(fieldSchema)
.load("f:/data/aa.csv")
taxiDF.registerTempTable("t_test")
val area = context.sql("select * from t_test")
area.show()
sparkContext.stop()