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 2021/04/28 02:13:03 UTC

[GitHub] [calcite] hannerwang commented on a change in pull request #2408: [CALCITE-4512] Optimize when GROUP BY or HAVING alias should be substituted with select item

hannerwang commented on a change in pull request #2408:
URL: https://github.com/apache/calcite/pull/2408#discussion_r621757009



##########
File path: core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml
##########
@@ -86,16 +86,19 @@ LogicalAggregate(group=[{0}])
             <![CDATA[select empno as d from emp group by d]]>
         </Resource>
     </TestCase>
-    <TestCase name="testGroupByAliasEqualToColumnName">
+    <TestCase name="testGroupByAliasEqualToMultipleColumnName">
         <Resource name="plan">
             <![CDATA[
 LogicalAggregate(group=[{0, 1}])
-  LogicalProject(EMPNO=[$0], DEPTNO=[$1])
-    LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+  LogicalProject(EMPNO=[$0], DEPTNO=[$7])
+    LogicalJoin(condition=[true], joinType=[inner])
+      LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+      LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
 ]]>
         </Resource>
         <Resource name="sql">
-            <![CDATA[select empno, ename as deptno from emp group by empno, deptno]]>
+            <![CDATA[select empno, case when emp.deptno is null then dept.deptno else emp.deptno
+end as deptno from emp, dept group by empno, deptno]]>
         </Resource>

Review comment:
       thanks for reviewing, the strategy that alias will be substituted has changed, so the case should be changed also.




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