Utkarsh Agarwal created SPARK-50749:
---------------------------------------
Summary: Fix ordering bug in
CommutativeExpression.gatherCommutative method
Key: SPARK-50749
URL: https://issues.apache.org/jira/browse/SPARK-50749
Project: Spark
Issue Type: Bug
Components: Optimizer
Affects Versions: 4.0.0
Reporter: Utkarsh Agarwal
[SPARK-49977](https://issues.apache.org/jira/browse/SPARK-49977) introduced a
bug in the `CommutativeExpression.gatherCommutative()` method, changing the
function's output order.
Consider the following concrete example:
```
val addExpression = Add(
Literal(1),
Add(
Literal(2),
Literal(3)
)
)
val commutativeExpressions = addExpression.gatherCommutative(addExpression,
\{ case Add(l, r, _) => Seq(l, r)})
```
Consider the output of the `gatherCommutative` method.
[SPARK-49977](https://issues.apache.org/jira/browse/SPARK-49977) introduced a
bug that reversed the output order. This PR fixes the bug in
`gatherCommutative()` to restore the original correct ordered output.
```
// Prior to SPARK-49977 and after this fix
// commutativeExpressions -> Seq(Literal(1), Literal(2), Literal(3)))
// Post SPARK-49977 and before this fix
// commutativeExpressions -> Seq(Literal(3), Literal(2), Literal(1)))
```
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]