Building the AirlineWrapper Scala trait

The AirlineWrapper contains code to create a SparkSession instance called session. It also declares case classes to represent our flights dataset. 

Let's create the trait definition first:

trait AirlineWrapper {  }

The entry point to programming is as follows: The first thing we do in the trait is to declare a lazy val called session. This is where we lazily create an instance of SparkSession. Lazily implies that the val is only executed when it is encountered the first time around. The session is our entry point to programming Spark with the DataSet and DataFrame API is SparkSession:

lazy val session = { SparkSession.builder()..getOrCreate() }

In the following code snippet, CarrierCode is an identification ...

Get Modern Scala Projects now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.