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/20 23:20:32 UTC
[GitHub] [calcite] amaliujia commented on a change in pull request #1985: [CALCITE-4011] Implement trait propagation for EnumerableProject…
amaliujia commented on a change in pull request #1985:
URL: https://github.com/apache/calcite/pull/1985#discussion_r428361297
##########
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:
I setup debugger and conformed that there was a `EnumerableSort` enforced for `EnumerableFilter`, however, I wasn't sure why planner always think that this plan is cheapest. In fact, I was hoping to see the following plan:
```
EnumerableProject(MGR=[$3])
EnumerableFilter(condition=[>($7, 10)])
EnumerableSort(sort0=[$3], dir0=[DESC])
EnumerableTableScan(table=[[CATALOG, SALES, EMP]])
```
----------------------------------------------------------------
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