I am new in SparkSQL, I am trying to parse and show the data of a JSON file. So My question is I cannot understand the Line number 2 in my code given below, why the builder function is not like the Documentation(.setAppName instead of .appName etc..) I have mentioned given below? What does mean of this added portion- "some-value").getOrCreate() in Line number 2 of my code? I will be thankful from the bottom of my heart if someone help me to understand this.
employee.json
{"name":"John", "age":28}
{"name":"Andrew", "age":36}
{"name":"Clarke", "age":22}
{"name":"Kevin", "age":42}
{"name":"Richard","age":51}
Code:
1. import org.apache.spark.sql.SparkSession
2. val spark = SparkSession.builder().appName("Spark SQL basic example").config("spark.some.config.option", "some-value").getOrCreate()
3. import spark.implicits._
4. val df = spark.read.json("examples/src/main/resources/employee.json")
5. df.show()
Output:
+---+-------+
|age| name|
+---+-------+
| 28| John|
| 36| Andrew|
| 22| Clarke|
| 42| Kevin|
| 51|Richard|
+---+-------+
=============================>>>>>>>>>> Please Note:
According to the Documentation of SparkConf passed to your SparkContext. SparkConf allows you to configure some of the common properties (e.g. master URL and application name), as well as arbitrary key-value pairs through the set() method. as follows::
val conf = new SparkConf().setMaster("local[2]").setAppName("CountingSheep")
val sc = new SparkContext(conf)