Chain transformations on orders, pick an action, and watch Spark cut the job into stages at every Exchange. Then size the cluster so no stage needs a second wave.
In progress| Stage | Description | Tasks | Waves | Input | Shuffle read | Shuffle write |
|---|---|---|---|---|---|---|
| 0 | Scan orders | 52 | 7 | 6.4 GB | — | 983 MB |
| 1 | Aggregate | 200 | 25 | — | 983 MB | — |
| Σ | 2 stages | 252 | 32 | sizes are estimates | ||
from pyspark.sql import SparkSession, functions as F
spark = (SparkSession.builder
.config("spark.executor.instances", "2")
.config("spark.executor.cores", "4")
.getOrCreate())
spark.conf.set("spark.sql.shuffle.partitions", "200")
spark.conf.set("spark.sql.adaptive.enabled", "false")
orders = spark.read.parquet("s3://lake/orders/") # 6.4 GB
result = (
orders
.filter(F.col("amount") > 100)
.groupBy("customer_id", "order_date")
.agg(F.sum("amount").alias("amount"))
)
# no action yet: Spark has only built a plan