- Spark Connector Python Guide >
- Aggregation
Aggregation¶
Use MongoDB’s aggregation pipeline to apply filtering rules and perform aggregation operations when reading data from MongoDB into Spark.
Consider a collection named fruit
that contains the
following documents:
Add the option()
method to spark.read()
from
within the pyspark
shell to specify an aggregation pipeline
to use when creating a DataFrame.
In the pyspark
shell, the operation prints the following output: