SparkSession的使用

SparkSession的使用

SparkSession是spark2.x版本中推行的,作为统一的spark入口

示例代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package com.anthony.spark
import org.apache.spark.sql.SparkSession
/**
* @Description:
* @Date: Created in 08:59 2018/3/28
* @Author: Anthony_Duan
*/
object SparkSessionApp {

def main(args: Array[String]): Unit = {

val spark = SparkSession.builder().appName("SparkSessionApp")
.master("local[2]").getOrCreate()

val fileDF = spark.read.json("file:///Users/duanjiaxing/data/test.json")
fileDF.show()
spark.stop()
}
}
-------------End Of This ArticleThank You For Reading-------------