JingsongLi commented on a change in pull request #9876: [FLINK-14134][table] Introduce LimitableTableSource for optimizing limit URL: https://github.com/apache/flink/pull/9876#discussion_r338967232
########## File path: flink-table/flink-table-planner-blink/src/test/resources/org/apache/flink/table/planner/plan/batch/sql/LimitTest.xml ########## @@ -144,6 +186,27 @@ LogicalSort(fetch=[0]) <Resource name="planAfter"> <![CDATA[ Values(type=[RecordType(INTEGER a, BIGINT b, VARCHAR(2147483647) c)], tuples=[[]], values=[a, b, c]) +]]> + </Resource> + </TestCase> + <TestCase name="testLimitWithLimitSource"> + <Resource name="sql"> + <![CDATA[SELECT a, c FROM LimitTable LIMIT 10]]> + </Resource> + <Resource name="planBefore"> + <![CDATA[ +LogicalSort(fetch=[10]) ++- LogicalProject(a=[$0], c=[$2]) + +- LogicalTableScan(table=[[default_catalog, default_database, LimitTable]]) +]]> + </Resource> + <Resource name="planAfter"> + <![CDATA[ +Calc(select=[a, c]) ++- Limit(offset=[0], fetch=[10], global=[true]) + +- Exchange(distribution=[single]) + +- Limit(offset=[0], fetch=[10], global=[false]) Review comment: And if we want to remove this local limit, we need check the child and check whether it is a `LimitableTableSource` in `BatchExecLimitRule`. This optimization is not worth the cost of coupling. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services