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/05/21 00:51:18 UTC

[GitHub] [calcite] hsyuan commented on a change in pull request #1985: [CALCITE-4011] Implement trait propagation for EnumerableProject…

hsyuan commented on a change in pull request #1985:
URL: https://github.com/apache/calcite/pull/1985#discussion_r428387288



##########
File path: core/src/test/resources/org/apache/calcite/test/TopDownOptTest.xml
##########
@@ -35,6 +35,46 @@ EnumerableLimit(fetch=[5])
   EnumerableSortedAggregate(group=[{3}], EXPR$1=[COUNT()])
     EnumerableSort(sort0=[$3], dir0=[DESC-nulls-last])
       EnumerableTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+        </Resource>
+    </TestCase>
+    <TestCase name="testSortProject">
+        <Resource name="sql">
+            <![CDATA[select mgr from sales.emp order by mgr desc nulls last]]>
+        </Resource>
+        <Resource name="planBefore">
+            <![CDATA[
+LogicalSort(sort0=[$0], dir0=[DESC-nulls-last])
+  LogicalProject(MGR=[$3])
+    LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+        </Resource>
+        <Resource name="planAfter">
+            <![CDATA[
+EnumerableProject(MGR=[$3])
+  EnumerableSort(sort0=[$3], dir0=[DESC-nulls-last])
+    EnumerableTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+        </Resource>
+    </TestCase>
+    <TestCase name="testSortFilter">
+        <Resource name="sql">
+            <![CDATA[select mgr from sales.emp where deptno > 10 order by mgr desc]]>
+        </Resource>
+        <Resource name="planBefore">
+            <![CDATA[
+LogicalSort(sort0=[$0], dir0=[DESC])
+  LogicalProject(MGR=[$3])
+    LogicalFilter(condition=[>($7, 10)])
+      LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+        </Resource>
+        <Resource name="planAfter">
+            <![CDATA[
+EnumerableProject(MGR=[$3])
+  EnumerableSort(sort0=[$3], dir0=[DESC])
+    EnumerableFilter(condition=[>($7, 10)])
+      EnumerableTableScan(table=[[CATALOG, SALES, EMP]])

Review comment:
       That makes sense, because it is cheaper.
   Let's think it another way.
   ```
   select a, b, c 
     from (select a, b, max(c) c from foo group by a, b) as t 
     where a+b+c>1 
   order by b desc, a desc;
   ```




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