Built with Tutify.io

    AIStudyLabs

    What is SparkSession

    What is SparkSession

    Spark SparkSession

    Since Apache Spark 2.0, SparkSession has become a unified entry point to Spark to work with RDD, DataFrame, and Dataset. Prior to 2.0, SparkContext used to be an entry point. spark-shell which is a CLI to interact with Spark provides a default Spark Session ‘spark‘ variable hence you don’t have to create one if you are using spark-shell.

    What is SparkSession

    SparkSession was introduced in version Spark 2.0, It is an entry point to underlying Spark functionality in order to programmatically create Spark RDD, DataFrame, and DataSet. SparkSession’s object spark is the default variable available in spark-shell and it can be created programmatically using SparkSession builder pattern.

    SparkSession in Spark 2.0

    How many SparkSessions can you create in an application?

    You can create as many SparkSession as you want in a Spark application using either SparkSession.builder() or SparkSession.newSession(). Many Spark session objects are required when you want to keep Spark tables (relational entities) logically separated.

    Table: Differences between MapReduce and Apache Spark

    | Feature | MapReduce | Apache Spark | | -------------------- | ----------------- | ---------------------- | | Processing Model | Disk-based | In-memory | | Speed | Slower | Faster | | Iterative Processing | Not efficient | Efficient | | Fault Tolerance | High | Moderate | | Ease of Use | Complex API | Simple API | | Language Support | Java, Python, C++ | Java, Python, Scala, R | | Streaming Support | Limited | Advanced |

    Summary and Key Takeaways

    In this lesson, we explored what SparkSession is and how it serves as a unified entry point in Apache Spark 2.0 and later. SparkSession combines multiple contexts into a single entry point and offers various APIs for Spark functionalities. We also compared MapReduce and Apache Spark to highlight their differences.

    Apache Spark Tutorial with Scala Examples — SparkSession & SparkContext

    Introduction to Apache Spark

    Setup Apache Spark Environment

    SparkSession & SparkContext

    Resilient Distributed Datasets (RDDs)

    Apache Spark Concepts

    Cache, Persistence and Shared Variables

    DataFrame Introduction

    DataFrame Narrow Transformation

    DataFrame Wider Transformation

    DataFrame Actions

    Spark SQL Functions

    Advanced DataFrame Features

    Using SQL Queries

    Spark Read & Write CSV Files

    Working with JSON Files

    Working with Parquet Files

    Spark Dataset

    What Next?

    Tutorial Not Found