Before running SQL queries on your dataset, you must register a temporary view for the dataset.
The following operation registers a
characters
table and then queries it to find all characters that
are 100 or older:
val characters = spark.read.format("mongodb").as[Character] characters.createOrReplaceTempView("characters") val centenarians = spark.sql("SELECT name, age FROM characters WHERE age >= 100") centenarians.show()