> For the complete documentation index, see [llms.txt](https://george-jen.gitbook.io/data-science-and-apache-spark/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://george-jen.gitbook.io/data-science-and-apache-spark/sparksession.md).

# SparkSession

The entry point into all functionality in Spark SQL is the SparkSession class. If you use spark-shell, SparkSession is automatically created for you.

Otherwise, you will need to create SparkSesison:

```
import org.apache.spark.sql.SparkSession
val spark = SparkSession
    .builder
    .appName("SQL example")
    .master("local[*]")
    .config("spark.sql.warehouse.dir", "file:///d:/tmp")
    .getOrCreate()
```

SparkSession is required for runing Spark SQL query.
