Docs Menu

Docs HomeMongoDB Spark Connector

Before you can run SQL queries against your DataFrame, you need to register a temporary table.

The following example registers a temporary table called temp, then uses SQL to query for records in which the type field contains the letter e:

some_fruit = spark.sql("SELECT type, qty FROM temp WHERE type LIKE '%e%'")

In the pyspark shell, the operation prints the following output:

| type| qty|
| apple| 5.0|
MongoDB Connector for Spark →
Share Feedback
© 2023 MongoDB, Inc.


  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2023 MongoDB, Inc.