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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.