fsk119 commented on a change in pull request #15307: URL: https://github.com/apache/flink/pull/15307#discussion_r607831711
########## File path: flink-table/flink-table-planner-blink/src/test/resources/org/apache/flink/table/planner/plan/rules/logical/PushFilterInCalcIntoTableSourceRuleTest.xml ########## @@ -0,0 +1,334 @@ +<?xml version="1.0" ?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to you under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> +<Root> + <TestCase name="testCannotPushDown"> + <Resource name="sql"> + <![CDATA[SELECT * FROM MyTable WHERE price > 10]]> + </Resource> + <Resource name="ast"> + <![CDATA[ +LogicalProject(name=[$0], id=[$1], amount=[$2], price=[$3]) ++- LogicalFilter(condition=[>($3, 10)]) + +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]]) +]]> + </Resource> + <Resource name="optimized rel plan"> + <![CDATA[ +LogicalProject(name=[$0], id=[$1], amount=[$2], price=[$3]) ++- LogicalFilter(condition=[>($3, 10)]) + +- LogicalTableScan(table=[[default_catalog, default_database, MyTable, filter=[]]]) +]]> + </Resource> + </TestCase> + <TestCase name="testCannotPushDown3"> + <Resource name="sql"> + <![CDATA[SELECT * FROM MyTable WHERE amount > 2 OR amount < 10]]> + </Resource> + <Resource name="ast"> + <![CDATA[ +LogicalProject(name=[$0], id=[$1], amount=[$2], price=[$3]) ++- LogicalFilter(condition=[OR(>($2, 2), <($2, 10))]) + +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]]) +]]> + </Resource> + <Resource name="optimized rel plan"> + <![CDATA[ +LogicalProject(name=[$0], id=[$1], amount=[$2], price=[$3]) ++- LogicalFilter(condition=[OR(>($2, 2), <($2, 10))]) + +- LogicalTableScan(table=[[default_catalog, default_database, MyTable, filter=[]]]) +]]> + </Resource> + </TestCase> + <TestCase name="testCannotPushDown3WithVirtualColumn"> + <Resource name="sql"> + <![CDATA[SELECT * FROM VirtualTable WHERE amount > 2 OR amount < 10]]> + </Resource> + <Resource name="ast"> + <![CDATA[ +LogicalProject(name=[$0], id=[$1], amount=[$2], virtualField=[$3], price=[$4]) ++- LogicalFilter(condition=[OR(>($2, 2), <($2, 10))]) + +- LogicalProject(name=[$0], id=[$1], amount=[$2], virtualField=[+($2, 1)], price=[$3]) + +- LogicalTableScan(table=[[default_catalog, default_database, VirtualTable]]) +]]> + </Resource> + <Resource name="optimized rel plan"> + <![CDATA[ +LogicalProject(name=[$0], id=[$1], amount=[$2], virtualField=[$3], price=[$4]) ++- LogicalProject(name=[$0], id=[$1], amount=[$2], virtualField=[+($2, 1)], price=[$3]) + +- LogicalFilter(condition=[OR(>($2, 2), <($2, 10))]) + +- LogicalTableScan(table=[[default_catalog, default_database, VirtualTable, filter=[]]]) +]]> + </Resource> + </TestCase> + <TestCase name="testFailureToPushFilterIntoSourceWithoutWatermarkPushdown"> + <Resource name="sql"> + <![CDATA[SELECT * FROM WithWatermark WHERE LOWER(name) = 'foo']]> + </Resource> + <Resource name="ast"> + <![CDATA[ +LogicalProject(name=[$0], event_time=[$1]) ++- LogicalFilter(condition=[=(LOWER($0), _UTF-16LE'foo')]) + +- LogicalWatermarkAssigner(rowtime=[event_time], watermark=[-($1, 5000:INTERVAL SECOND)]) + +- LogicalTableScan(table=[[default_catalog, default_database, WithWatermark]]) +]]> + </Resource> + <Resource name="optimized rel plan"> + <![CDATA[ +FlinkLogicalCalc(select=[name, event_time], where=[=(LOWER(name), _UTF-16LE'foo':VARCHAR(2147483647) CHARACTER SET "UTF-16LE")]) ++- FlinkLogicalWatermarkAssigner(rowtime=[event_time], watermark=[-($1, 5000:INTERVAL SECOND)]) + +- FlinkLogicalTableSourceScan(table=[[default_catalog, default_database, WithWatermark]], fields=[name, event_time]) +]]> + </Resource> + </TestCase> + <TestCase name="testCannotPushDownWithVirtualColumn"> + <Resource name="sql"> + <![CDATA[SELECT * FROM VirtualTable WHERE price > 10]]> + </Resource> + <Resource name="ast"> + <![CDATA[ +LogicalProject(name=[$0], id=[$1], amount=[$2], virtualField=[$3], price=[$4]) ++- LogicalFilter(condition=[>($4, 10)]) + +- LogicalProject(name=[$0], id=[$1], amount=[$2], virtualField=[+($2, 1)], price=[$3]) + +- LogicalTableScan(table=[[default_catalog, default_database, VirtualTable]]) +]]> + </Resource> + <Resource name="optimized rel plan"> + <![CDATA[ +LogicalProject(name=[$0], id=[$1], amount=[$2], virtualField=[$3], price=[$4]) ++- LogicalProject(name=[$0], id=[$1], amount=[$2], virtualField=[+($2, 1)], price=[$3]) + +- LogicalFilter(condition=[>($3, 10)]) + +- LogicalTableScan(table=[[default_catalog, default_database, VirtualTable, filter=[]]]) +]]> + </Resource> + </TestCase> + <TestCase name="testCanPushDown"> + <Resource name="sql"> + <![CDATA[SELECT * FROM MyTable WHERE amount > 2]]> + </Resource> + <Resource name="ast"> + <![CDATA[ +LogicalProject(name=[$0], id=[$1], amount=[$2], price=[$3]) ++- LogicalFilter(condition=[>($2, 2)]) + +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]]) +]]> + </Resource> + <Resource name="optimized rel plan"> + <![CDATA[ +LogicalProject(name=[$0], id=[$1], amount=[$2], price=[$3]) ++- LogicalTableScan(table=[[default_catalog, default_database, MyTable, filter=[greaterThan(amount, 2)]]]) +]]> + </Resource> + </TestCase> + <TestCase name="testCanPushDownWithVirtualColumn"> + <Resource name="sql"> + <![CDATA[SELECT * FROM VirtualTable WHERE amount > 2]]> + </Resource> + <Resource name="ast"> + <![CDATA[ +LogicalProject(name=[$0], id=[$1], amount=[$2], virtualField=[$3], price=[$4]) ++- LogicalFilter(condition=[>($2, 2)]) + +- LogicalProject(name=[$0], id=[$1], amount=[$2], virtualField=[+($2, 1)], price=[$3]) + +- LogicalTableScan(table=[[default_catalog, default_database, VirtualTable]]) +]]> + </Resource> + <Resource name="optimized rel plan"> + <![CDATA[ +LogicalProject(name=[$0], id=[$1], amount=[$2], virtualField=[$3], price=[$4]) ++- LogicalProject(name=[$0], id=[$1], amount=[$2], virtualField=[+($2, 1)], price=[$3]) + +- LogicalTableScan(table=[[default_catalog, default_database, VirtualTable, filter=[greaterThan(amount, 2)]]]) +]]> + </Resource> + </TestCase> + <TestCase name="testFullyPushDown"> + <Resource name="sql"> + <![CDATA[SELECT * FROM MyTable WHERE amount > 2 AND amount < 10]]> + </Resource> + <Resource name="ast"> + <![CDATA[ +LogicalProject(name=[$0], id=[$1], amount=[$2], price=[$3]) ++- LogicalFilter(condition=[AND(>($2, 2), <($2, 10))]) + +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]]) +]]> + </Resource> + <Resource name="optimized rel plan"> + <![CDATA[ +LogicalProject(name=[$0], id=[$1], amount=[$2], price=[$3]) ++- LogicalTableScan(table=[[default_catalog, default_database, MyTable, filter=[and(greaterThan(amount, 2), lessThan(amount, 10))]]]) +]]> Review comment: Why LogicalTableScan? It should be FlinkLogicalTableSourceScan. -- 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