The full answer
DPP only prunes partition columns, generally needs the filtering side to be broadcast, works only for certain join shapes, and only helps when the filter is selective and the data source supports it. Each limitation has a workaround, but often the real answer is a better table layout or a different skipping technique.
| Limitation | Why it happens | How to address it |
|---|---|---|
| Only partition columns | DPP skips partition directories, not rows or files | Partition large fact tables by the commonly joined key (often a date); for other columns use runtime Bloom filters, Delta data skipping with Z-ordering or liquid clustering, or Iceberg's file statistics |
| Small side must be broadcast (by default) | Spark reuses the broadcast to avoid computing the dimension twice | Filter the dimension further, raise spark.sql.autoBroadcastJoinThreshold within memory limits, or add a broadcast() hint |
| Equi-joins on the bare column only | A function or cast around the key hides the partition column | Join on the column itself with matching types; store keys in the same type in both tables |
| Join type restrictions | Pruning one side of an outer join would drop rows that must be kept | Rewrite as an inner join where the logic allows it, or filter the fact table explicitly |
| Low selectivity | If most partitions match, pruning saves little | Accept it, or change partition granularity |
| Source support | Needs a file index or runtime filtering support | Use Parquet, ORC, Delta or Iceberg tables; for JDBC sources push filters into the query instead |
| Over-partitioning | Partitioning by a high-cardinality key to make DPP work creates many small files and slow listing | Keep partitions coarse (day or month); combine with file-level skipping |
| Planning overhead | Extra subqueries and listing in very complex queries | Usually negligible; measure if planning time is high |
| Wrong estimates | Missing statistics stop broadcasts | ANALYZE TABLE ... COMPUTE STATISTICS, and keep adaptive query execution on |
Explicit alternative when DPP doesn't apply Compute the keys yourself and filter the fact table on the partition column; static partition pruning then applies:
from pyspark.sql import functions as F
q1_dates = [r.date_id for r in dates.filter("quarter = 'Q1'").select("date_id").collect()]
sales_q1 = sales.filter(F.col("date_id").isin(q1_dates))
Only do this when the key list is small.
Checking it worked
explain("formatted") shows dynamicpruningexpression(... IN dynamicpruning#...) when DPP applies, and dynamicpruningexpression(true) when Spark decided not to prune. Compare partitions read with the total in the Spark UI's SQL tab.
The overall lesson: DPP is a free bonus when tables are partitioned well and joins follow a star schema; it isn't a substitute for a good layout.
Last updated 16 October 2026
Sources