You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2020/01/02 12:25:00 UTC

[GitHub] [calcite] 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

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_r362456472
 
 

 ##########
 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:
   Currently select list is given as '*' when `wrapSelect` [1], however it's seems not right for this case.
   Shall we set the correct alias for such case ?
   
   [1] https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java#L437

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services