viirya commented on code in PR #39508:
URL: https://github.com/apache/spark/pull/39508#discussion_r1083698974


##########
sql/core/src/test/resources/sql-tests/inputs/group-by.sql:
##########
@@ -45,6 +45,15 @@ SELECT COUNT(DISTINCT b), COUNT(DISTINCT b, c) FROM (SELECT 
1 AS a, 2 AS b, 3 AS
 SELECT a AS k, COUNT(b) FROM testData GROUP BY k;
 SELECT a AS k, COUNT(b) FROM testData GROUP BY k HAVING k > 1;
 
+-- GROUP BY alias is not triggered if SELECT list has lateral column alias.
+SELECT 1 AS x, x + 1 AS k FROM testData GROUP BY k;
+
+-- GROUP BY alias is not triggered if SELECT list has outer reference.
+SELECT * FROM testData WHERE a = 1 AND EXISTS (SELECT a AS k GROUP BY k);
+
+-- GROUP BY alias inside subquery expression with conflicting outer reference
+SELECT * FROM testData WHERE a = 1 AND EXISTS (SELECT 1 AS a GROUP BY a);
+

Review Comment:
   GROUP BY alias takes precedence than outer reference?



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