Package cells
To use custom Scala classes and objects defined within notebooks reliably in Spark and across notebook sessions, you should define classes in package cells. A package cell is a cell that is compiled when it is run. A package cell has no visibility with respect to the rest of the notebook. You can think of it as a separate Scala file. Only class
and object
definitions can go in a package cell. You cannot have any values, variables, or function definitions.
The following notebook shows what can happen if you do not use package cells and provides some examples, caveats, and best practices.
Notebook example: package cells
The following notebook shows an example of how to package cells.