xiedeyantu commented on code in PR #4417:
URL: https://github.com/apache/calcite/pull/4417#discussion_r2155807386


##########
core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java:
##########
@@ -6589,12 +6610,14 @@ public boolean isBangEqualAllowed() {
     sql("select deptno + empno as d, deptno + empno + mgr from emp"
         + " group by d,mgr")
         .withConformance(lenient).ok();
-    // When alias is equal to one or more columns in the query then giving
-    // priority to alias. But Postgres may throw ambiguous column error or give
-    // priority to column name.
+    // Alias is not used since there is a single column in the SELECT already 
matching
     sql("select count(*) from (\n"
-        + "  select ename AS deptno FROM emp GROUP BY deptno) t")
-        .withConformance(lenient).ok();
+        + "  select ^ename^ AS deptno FROM emp GROUP BY deptno) t")
+        .withConformance(strict)
+        .fails("Expression 'ENAME' is not being grouped")
+        .withConformance(lenient)

Review Comment:
   > // This behavior is from MySQL:
   > // - if there is no column in the SELECT with the name used in the GROUP 
BY or HAVING,
   > //   then look for a column alias in the SELECT
   > // - if there are multiple columns in the SELECT with the name used in the 
GROUP BY or
   > //   HAVING, then also look for a column alias in the SELECT
   
   Given the description above, should this test using lenient pass? Does the 
original description of this case seem correct?



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