FailedChanges

Summary

  1. [SPARK-35767][SQL] Avoid executing child plan twice in CoalesceExec (details)
Commit 0ef0f4f7dcf783a77635f71a06163550fd2f46a6 by dongjoon
[SPARK-35767][SQL] Avoid executing child plan twice in CoalesceExec

### What changes were proposed in this pull request?

`CoalesceExec` needlessly calls `child.execute` twice when it could just call it once and re-use the results. This only happens when `numPartitions == 1`.

### Why are the changes needed?

It is more efficient to execute the child plan once rather than twice.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

There are no functional changes. This is just a performance optimization, so the existing tests should be sufficient to catch any regressions.

Closes #32920 from andygrove/coalesce-exec-executes-twice.

Authored-by: Andy Grove <andygrove73@gmail.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
(cherry picked from commit 1012967ace4c7bd4e5a6f59c6ea6eec45871f292)
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
The file was modifiedsql/core/src/main/scala/org/apache/spark/sql/execution/basicPhysicalOperators.scala (diff)