Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Investigate and resolve caching, skewing, spilling, and shuffle issues by using a Directed Acyclic Graph (DAG), the Spark UI, and query profile

A worked example

Yes or no

A data engineer runs the following code on a classic Azure Databricks cluster. Photon is disabled, and all Spark settings use their default values.

orders = spark.read.table("sales.orders").repartition(400)
customers = spark.read.table("sales.customers")
result = orders.join(customers, "customer_id")

The customers data is about 45 MB when the join runs. The join runs as a sort-merge join. In the Spark UI, the Summary Metrics of the join stage show a Max task duration more than three times the 75th percentile. Further investigation confirms that a few disproportionately large partitions account for the slow tasks and their spill. The stage metrics are shown in the exhibit.

StageDurationShuffle ReadShuffle WriteShuffle Spill (Memory)Shuffle Spill (Disk)
Join stage9.2 min38.6 GiB0 B21.4 GiB7.9 GiB

For each of the following statements, select Yes if the statement is true. Otherwise, select No.

StatementYesNo
With the cluster's default configuration, AQE can automatically broadcast the customers DataFrame when converting this join at runtime.

The source gives a default runtime broadcast threshold of 30 MB for spark.databricks.adaptive.autoBroadcastJoinThreshold. At about 45 MB, customers exceeds that threshold and is not eligible for automatic broadcast.

Correct
The repartition(400) call on orders triggers a full shuffle of the orders data.

Each call to repartition() triggers a full shuffle, so this call adds shuffle work; avoiding unnecessary repartitioning is one way to reduce shuffle.

Correct
Because the stage shows both spill and skew, the engineer should address the skew before adding worker memory to reduce the spill.

Spill often accompanies skew because one oversized partition spills to disk. The guidance is to address skew first, as the spill often resolves as a side effect.

Correct
Why

The 45 MB customers input exceeds AQE's default 30 MB runtime broadcast threshold, so AQE cannot automatically broadcast that input under the current settings. The repartition(400) operation introduces a full shuffle of orders. Non-zero spill metrics indicate memory pressure, and the investigation confirms that oversized partitions cause the slow tasks and spill. Addressing that skew first can reduce spill without adding worker memory.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free