mihailoale-db opened a new pull request, #51186:
URL: https://github.com/apache/spark/pull/51186

   ### What changes were proposed in this pull request?
   For the following query:
   ```
   SELECT col1 AS alias
   FROM values(named_struct('a', 1))
   GROUP BY col1
   HAVING (
   SELECT col1.a = 1
   );
   ```
   this is the resulting analyzed plan:
   ```
   Filter cast(scalar-subquery#8847 [alias#8846] as boolean)
   :  +- Project [(outer(alias#8846).a = 1) AS (outer(col1).a AS a = 1)#8867]
   :     +- OneRowRelation
   +- Aggregate [col1#8865], [col1#8865 AS alias#8846]
      +- LocalRelation [col1#8865]
   ```
   As it can be seen, we have outer(col1).a AS a in the Alias name for col1.a = 
1 which is redundant and should be removed. It doesn't affect the output schema 
so changing the Alias name here is safe.
   
   After the change, plan looks like:
   ```
   Filter cast(scalar-subquery#x [alias#x] as boolean)
   :  +- Project [(outer(alias#x).a = 1) AS (outer(col1).a = 1)#x]
   :     +- OneRowRelation
   +- Aggregate [col1#x], [col1#x AS alias#x]
      +- LocalRelation [col1#x]
   ```
   
   ### Why are the changes needed?
   To keep the compatibility between fixed-point and single-pass 
implementations. 
   
   ### Does this PR introduce _any_ user-facing change?
   No.
   
   ### How was this patch tested?
   Tests added in this PR.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   No.


-- 
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]

Reply via email to