peter-toth opened a new pull request, #37334:
URL: https://github.com/apache/spark/pull/37334

   ### What changes were proposed in this pull request?
   Keep the output attributes of a `Union` node's first child in the 
`RemoveRedundantAliases` rule to avoid correctness issues.
   
   ### Why are the changes needed?
   To fix the result of the following query:
   ```
   SELECT a, b AS a FROM (
     SELECT a, a AS b FROM (SELECT a FROM VALUES (1) AS t(a))
     UNION ALL
     SELECT a, b FROM (SELECT a, b FROM VALUES (1, 2) AS t(a, b))
   )
   ```
   Before this PR the query returns the incorrect result: 
   ```
   +---+---+
   |  a|  a|
   +---+---+
   |  1|  1|
   |  2|  2|
   +---+---+
   ```
   After this PR it returns the expected result:
   ```
   +---+---+
   |  a|  a|
   +---+---+
   |  1|  1|
   |  1|  2|
   +---+---+
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   Yes, fixes a correctness issue.
   
   ### How was this patch tested?
   Added new UTs.


-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to