jinxing64 commented on a change in pull request #1715: [CALCITE-3662] Generate 
wrong SQL when plan contains Project(Sort(Aggregate)) and aggregate field has 
no alias
URL: https://github.com/apache/calcite/pull/1715#discussion_r362756548
 
 

 ##########
 File path: piglet/src/test/java/org/apache/calcite/test/PigRelOpTest.java
 ##########
 @@ -468,14 +468,14 @@ private Fluent pig(String script) {
         + "HIREDATE, SAL, COMM, DEPTNO)) AS A\n"
         + "            FROM scott.EMP\n"
         + "            GROUP BY DEPTNO) AS $cor4,\n"
-        + "          LATERAL (SELECT COLLECT(ROW(ENAME, JOB, DEPTNO, SAL)) AS 
X\n"
-        + "            FROM (SELECT ENAME, JOB, DEPTNO, SAL\n"
+        + "          LATERAL (SELECT X\n"
+        + "            FROM (SELECT 'all' AS $f0, COLLECT(ROW(ENAME, JOB, 
DEPTNO, SAL)) AS X\n"
         + "                  FROM UNNEST (SELECT $cor4.A AS $f0\n"
         + "                        FROM (VALUES  (0)) AS t (ZERO)) "
         + "AS t2 (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)\n"
         + "                  WHERE JOB <> 'CLERK'\n"
-        + "                  ORDER BY SAL) AS t5\n"
-        + "            GROUP BY 'all') AS t8) AS $cor5,\n"
+        + "                  GROUP BY 'all'\n"
+        + "                  ORDER BY SAL) AS t7) AS t8) AS $cor5,\n"
         + "    LATERAL UNNEST (SELECT $cor5.X AS $f0\n"
 
 Review comment:
   If we rectify the alias for subquery, above case I mentioned should work 
well.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to