Step 2 - Register both DataFrames as temp tables to make querying easier

To register both datasets, we can use the following code:

ratingsDF.createOrReplaceTempView("ratings")moviesDF.createOrReplaceTempView("movies")

This will help to make in-memory querying faster by creating a temporary view as a table in the memory. The lifetime of the temporary table using the createOrReplaceTempView () method is tied to [[SparkSession]], which was used to create this DataFrame.

Get Scala Machine Learning 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.