Adaptive query execution (AQE) adjusts the query plan during execution using the real statistics of the previous stages: merging small partitions after a shuffle, changing the join strategy, handling skewed partitions. It is enabled by default in recent Spark versions.
Example
spark.conf.set('spark.sql.adaptive.enabled', 'true')