Courseiva

Databricks-DE-Pro Developing Code (Python/SQL) Practice Question

A data engineer is developing a PySpark job that reads a large Delta table, performs a groupBy on a high-cardinality column, and writes the result to another Delta table. The job is experiencing performance issues due to data skew. The engineer wants to optimize the shuffle by using salting. Which approach correctly implements salting to distribute the skewed keys evenly?

⚠ Common exam trap

The trap here is thinking that repartitioning on the skewed column or relying solely on Adaptive Query Execution will resolve severe skew, when salting is often required for even distribution.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Add a random salt column to the DataFrame, group by the salted column, then remove the salt and re-aggregate.

Salting is a technique to distribute skewed keys by appending a random salt to the key before the shuffle, then grouping by the salted key, and finally removing the salt and re-aggregating to get the correct results. This spreads the load of a hot key across multiple partitions. The other options do not correctly implement salting or fail to address the skew.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Use repartition on the skewed column before the groupBy to increase parallelism.

    Why it's wrong here

    Repartitioning on the skewed column will not solve skew because the hash partitioning will still send all identical keys to the same partition. It may increase the number of partitions but does not distribute a single hot key. This approach fails to address the root cause of skew, which is a single key dominating a partition.

  • ✓

    Add a random salt column to the DataFrame, group by the salted column, then remove the salt and re-aggregate.

    Why this is correct

    Salting involves adding a random suffix to the skewed key to distribute it across partitions. The approach of adding a salt, grouping by the salted key, then removing the salt and re-aggregating is a standard technique. It ensures even distribution during the shuffle and correct final aggregation. This is the correct implementation for mitigating skew.

  • ✗

    Use broadcast join instead of groupBy to avoid the shuffle.

    Why it's wrong here

    Broadcast join is used for joins, not groupBy aggregations. It cannot replace a groupBy operation. While it avoids shuffle for joins, it is irrelevant here. The engineer needs to optimize a groupBy, so broadcast join is not applicable. This option misunderstands the operation being optimized.

  • ✗

    Set spark.sql.adaptive.enabled to true and rely on Adaptive Query Execution to handle skew automatically.

    Why it's wrong here

    Adaptive Query Execution can mitigate skew by splitting skewed partitions, but it does not always fully resolve severe skew, especially with very large keys. It is a helpful optimization but not a guaranteed fix. The question asks for a salting implementation, and AQE is not salting. Therefore, this is not the correct approach.

About these practice questions

This Databricks-DE-Pro question is part of Courseiva's 267-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Databricks exam blueprint

This Databricks-DE-Pro practice question is part of Courseiva's free Databricks certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the Databricks-DE-Pro exam.