dssysolyatin commented on code in PR #4491:
URL: https://github.com/apache/calcite/pull/4491#discussion_r2256548582


##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -2210,7 +2210,7 @@ private static String toSql(RelNode root, SqlDialect 
dialect,
         + "INNER JOIN \"foodmart\".\"sales_fact_1997\" ON 
\"product\".\"product_id\" = \"sales_fact_1997\".\"product_id\"\n"
         + "GROUP BY \"product\".\"product_id\"\n"
         + "HAVING COUNT(*) > 1) AS \"t2\"\n"
-        + "WHERE \"t2\".\"product_id\" > 100";
+        + "WHERE \"product_id\" > 100";

Review Comment:
   I don't think I should avoid making this change. The alias t2 appears 
because a JOIN is used in the subquery. But if we remove the join, like this:
   
   ```
   select * from (select "product"."product_id",
       min("product"."product_id")
       from "product"
       group by "product"."product_id"
       having count(*) > 1) where "product_id" > 100;
   ```
   
   Then both the old and new versions return the same result, which does not 
have `t2` before `product_id`
   ```
   SELECT *
   FROM (
       SELECT "product_id", MIN("product_id") AS "EXPR$1"
       FROM "foodmart"."product"
       GROUP BY "product_id"
       HAVING COUNT(*) > 1
   ) AS "t2"
   WHERE "product_id" > 100;
   ```
   
   So basically, it unifies the behavior, and JOIN inside the subquery does not 
affect anything outside of subquery
   



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

Reply via email to