concept session in category spark

appears as: session, Session, sessions
Spark in Action, Second Edition

This is an excerpt from Manning's book Spark in Action, Second Edition.

For every Spark application, the first operation is to connect to the Spark master and get a Spark session . This is an operation you will do every time. This is illustrated by the code fragment in listing 2.3 and by figure 2.4.

...
[INFO] --- exec-maven-plugin:1.6.0:exec (default-cli) @ spark-chapter04 --- #1
1. Creating a session .............. 1791 #2
2. Loading initial dataset ......... 3287 #2
3. Building full dataset ........... 242 #2
4. Clean-up ........................ 8 #2
5. Transformations ................ 0 #3
6. Final action .................... 20770 #4
 
# of records ....................... 2487641
...
[INFO] --- exec-maven-plugin:1.6.0:exec (default-cli) @ spark-chapter04 --- #5
1. Creating a session .............. 1553  #2
2. Loading initial dataset ......... 3197  #2
3. Building full dataset ........... 208   #2
4. Clean-up ........................ 8     #2
5. Transformations ................ 182    #3
6. Final action .................... 34061 #4
 
# of records ....................... 2487641
...
[INFO] --- exec-maven-plugin:1.6.0:exec (default-cli) @ spark-chapter04 --- #6
1. Creating a session .............. 1903  #2
2. Loading initial dataset ......... 3184  #2
3. Building full dataset ........... 213   #2
4. Clean-up ........................ 8     #2
5. Transformations ................ 205    #3
6. Final action .................... 24909 #4
 
# of records ....................... 2487641
...
 [INFO] Total time: 37.659 s #7

To enable a table-like SQL usage in Spark, you have to create a view. The scope can be local (to the session) as you just did, or global (to the application). You can find more details on local versus global scopes in the next section.

Figure 17.6 Delta Lake sits within Spark and allows sessions to access datasets.