Spark SQL
Query data.
What Is Spark SQL?
Spark SQL lets you query distributed data with standard SQL or a typed DataFrame API. Both go through the same Catalyst optimizer, so they perform identically.
Temporary Views
To run SQL against a DataFrame, register it as a view. createOrReplaceTempView makes it queryable by name for the current session.
val df = Seq(("Alice", 30), ("Bob", 25)).toDF("name", "age")
df.createOrReplaceTempView("people")