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 2019/03/27 07:14:26 UTC

[GitHub] [calcite] chunweilei commented on a change in pull request #912: [CALCITE-2729] introducing WindowReduceExpressionsRule

chunweilei commented on a change in pull request #912: [CALCITE-2729] introducing WindowReduceExpressionsRule
URL: https://github.com/apache/calcite/pull/912#discussion_r269429047
 
 

 ##########
 File path: core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
 ##########
 @@ -8674,4 +8674,32 @@ LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$
             <![CDATA[select * from emp where MGR > 0 and case when MGR > 0 then deptno / MGR else null end > 1]]>
         </Resource>
     </TestCase>
+    <TestCase name="testReduceConstantsWindow">
+        <Resource name="sql">
+            <![CDATA[select col1, col2, col3
+from (
+  select empno,
+    sum(100) over (partition by deptno, sal order by sal) as col1,
+    sum(100) over (partition by deptno order by deptno) as col2,
+    sum(sal) over (partition by deptno order by sal) as col3
+  from emp where sal = 5000)
+]]>
+        </Resource>
+        <Resource name="planAfter">
+            <![CDATA[
+LogicalProject($0=[$2], $1=[$3], $2=[$4])
+  LogicalWindow(window#0=[window(partition {1} order by [] range between UNBOUNDED PRECEDING and CURRENT ROW aggs [SUM($2)])], window#1=[window(partition {} order by [1] range between UNBOUNDED PRECEDING and CURRENT ROW aggs [SUM($2)])], window#2=[window(partition {1} order by [] range between UNBOUNDED PRECEDING and CURRENT ROW aggs [SUM(5000)])])
 
 Review comment:
   When creating LogicalWindow, it will identify constants in the expression tree and replace them with references to newly generated constant pool[1]. 
   
   [1]https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/rel/logical/LogicalWindow.java#L116

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