Built with Tutify.io

    AIStudyLabs

    What is SparkSession

    What is SparkSession

    PySpark SparkSession

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

    SparkSession in Spark 2.0

    from pyspark.sql import SparkSession
    
    spark = SparkSession.builder \
        .appName("example") \
        .getOrCreate()
    
    sc = spark.sparkContext
    

    How many SparkSessions can you create in an application?

    In a PySpark application, you can create multiple SparkSession instances using either SparkSession.builder() or SparkSession.newSession(). This is useful when you need to keep Spark tables (relational entities) logically separated.

    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.

    Introduction to PySpark for Data Engineering — SparkSession & SparkContext

    Introduction to PySpark

    Setup PySpark 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

    PySpark SQL Functions

    Advanced DataFrame Features

    PySpark SQL

    Spark Read & Write CSV Files

    Working with JSON Files

    Working with Parquet Files

    What Next?

    Tutorial Not Found