zml1206 opened a new pull request, #40182:
URL: https://github.com/apache/spark/pull/40182
### What changes were proposed in this pull request?
Extend the CollapseWindow rule to collapse Window nodes with the equivalent
partition/order expressions
### Why are the changes needed?
```
Seq((1, 1), (2, 2)).toDF("a", "b")
.withColumn("max_b", expr("max(b) OVER (PARTITION BY abs(a))"))
.withColumn("min_b", expr("min(b) OVER (PARTITION BY abs(a))"))
== Optimized Logical Plan ==
before
Project [a#7, b#8, max_b#11, min_b#17]
+- Window [min(b#8) windowspecdefinition(_w0#19,
specifiedwindowframe(RowFrame, unboundedpreceding$(), unboundedfollowing$()))
AS min_b#17], [_w0#19]
+- Project [a#7, b#8, max_b#11, abs(a#7) AS _w0#19]
+- Window [max(b#8) windowspecdefinition(_w0#13,
specifiedwindowframe(RowFrame, unboundedpreceding$(), unboundedfollowing$()))
AS max_b#11], [_w0#13]
+- Project [_1#2 AS a#7, _2#3 AS b#8, abs(_1#2) AS _w0#13]
+- LocalRelation [_1#2, _2#3]
after
Project [a#7, b#8, max_b#11, min_b#17]
+- Window [max(b#8) windowspecdefinition(_w0#13,
specifiedwindowframe(RowFrame, unboundedpreceding$(), unboundedfollowing$()))
AS max_b#11, min(b#8) windowspecdefinition(_w0#13,
specifiedwindowframe(RowFrame, unboundedpreceding$(), unboundedfollowing$()))
AS min_b#17], [_w0#13]
+- Project [_1#2 AS a#7, _2#3 AS b#8, abs(_1#2) AS _w0#13]
+- LocalRelation [_1#2, _2#3]
```
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
UT
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]