Free Databricks-Certified-Associate-Developer-for-Apache-Spark-3.5 Actual Exam Questions - Question 11 Discussion
result = df.coalesce(20)
How many partitions will the result DataFrame have?
A imo, coalesce only increases partitions if shuffle=True, which isn’t mentioned here.
It’s A, coalesce can’t increase partitions without shuffle, so stays 10 here.
Makes sense to rule out 20 since coalesce typically reduces partitions without shuffle. So the safe bet is A, sticking with the original 10 partitions.
Guessing A. Coalesce usually just merges partitions and doesn’t increase them unless shuffle=true, which isn’t mentioned here, so the count should stay at 10.
Yeah, I’m with option A here. Coalesce by default tries to avoid a shuffle and only reduces partitions, so it won’t bump the count up from 10 to 20. It basically just sticks with what it has if you ask for more partitions than exist.
D imo, coalesce is meant for reducing partitions without full shuffle, so if you ask for more than you have, it just keeps the original count. Since df has 10 partitions, asking for 20 won’t magically increase them. So the result should still have 10 partitions.
A imo. Coalesce is mainly used to reduce the number of partitions, not increase them. Since the original DataFrame has 10 partitions, calling coalesce(20) won’t actually create more partitions. It’ll just keep it at 10, so the result should still have 10 partitions.
Probably A. coalesce usually reduces the number of partitions but doesn't increase them, so it should stay at 10 here.