andylam-db commented on code in PR #47388:
URL: https://github.com/apache/spark/pull/47388#discussion_r1688724686
##########
sql/core/src/test/resources/sql-tests/inputs/subquery/scalar-subquery/scalar-subquery-group-by.sql:
##########
@@ -15,10 +15,15 @@ select * from x where (select count(*) from y where y1 > x1
group by x1) = 1;
select *, (select count(*) from y where x1 = y1 and y2 = 1 group by y2) from x;
-- Group-by column equal to expression with constants and outer refs - legal
select *, (select count(*) from y where x1 = y1 and y2 = x1 + 1 group by y2)
from x;
+-- Group-by expression is the same as the one we filter on - legal
+select *, (select count(*) from y where x1 = y1 and cast(y2 as double) = x1 + 1
+ group by cast(y2 as double)) from x;
+
-- Illegal queries
select * from x where (select count(*) from y where y1 > x1 group by y1) = 1;
select *, (select count(*) from y where y1 + y2 = x1 group by y1) from x;
+select *, (select count(*) from y where x1 = y1 and y2 + 10 = x1 + 1 group by
y2) from x;
Review Comment:
1. I'm not really sure how these new test cases reflect the changes made in
the code. Could you elaborate how `Group-by expression is the same as the one
we filter on` is legal and why the other one is illegal?
- edit: the idea is grouping expressions need to be present as a whole in
predicates.
2. Could you also more test cases for the positive and negative cases you
commented in `getEquivalentToOuter`?
--
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]