peter-toth commented on code in PR #37334:
URL: https://github.com/apache/spark/pull/37334#discussion_r934520233
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala:
##########
@@ -559,6 +561,34 @@ object RemoveRedundantAliases extends Rule[LogicalPlan] {
})
Join(newLeft, newRight, joinType, newCondition, hint)
+ case _: Union =>
+ var first = true
+ plan.mapChildren { child =>
+ if (first) {
+ first = false
+ child match {
+ case p: Project =>
+ var passThroughAttributes =
+ AttributeSet(p.projectList.filter(_.isInstanceOf[Attribute]))
Review Comment:
https://github.com/apache/spark/pull/37334/commits/608f83a3c4d2cde3a8787d7412af7cbe2ed045e7
would be the change if we always wanted to guarantee it.
But it looks like an extra exchange is inserted into q70:
https://github.com/apache/spark/pull/37334/commits/d212dabcd8af7021f615e6bc741885d580e1df52:
```
(24) HashAggregate [codegen id : 5]
Input [2]: [s_state#13, sum#16]
Keys [1]: [s_state#13]
Functions [1]: [sum(UnscaledValue(ss_net_profit#10))]
Aggregate Attributes [1]: [sum(UnscaledValue(ss_net_profit#10))#17]
-Results [3]: [s_state#13, s_state#13,
MakeDecimal(sum(UnscaledValue(ss_net_profit#10))#17,17,2) AS _w2#18]
+Results [3]: [s_state#13 AS s_state#18, s_state#13,
MakeDecimal(sum(UnscaledValue(ss_net_profit#10))#17,17,2) AS _w2#19]
-(25) Sort [codegen id : 5]
-Input [3]: [s_state#13, s_state#13, _w2#18]
-Arguments: [s_state#13 ASC NULLS FIRST, _w2#18 DESC NULLS LAST], false, 0
+(25) Exchange
+Input [3]: [s_state#18, s_state#13, _w2#19]
+Arguments: hashpartitioning(s_state#13, 5), ENSURE_REQUIREMENTS, [plan_id=3]
-(26) Window
-Input [3]: [s_state#13, s_state#13, _w2#18]
-Arguments: [rank(_w2#18) windowspecdefinition(s_state#13, _w2#18 DESC NULLS
LAST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS
ranking#19], [s_state#13], [_w2#18 DESC NULLS LAST]
+(26) Sort [codegen id : 6]
+Input [3]: [s_state#18, s_state#13, _w2#19]
+Arguments: [s_state#13 ASC NULLS FIRST, _w2#19 DESC NULLS LAST], false, 0
```
and I'm not sure yet why. Tomorrow I can take a deeper look at it...
--
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]