Abhishek Baranwal explains the differences between the SparkSession object and the SparkContext object when writing Spark code:
Prior to spark 2.0, SparkContext was used as a channel to access all spark functionality. The spark driver program uses sparkContext to connect to the cluster through resource manager.
SparkConf is required to create the spark context object, which stores configuration parameters like appName (to identify your spark driver), number core and memory size of executor running on worker node.
In order to use API’s of SQL, Hive, and Streaming, separate context needs to be created.
Read on to see where SparkSession fits in.