hequn8128 commented on a change in pull request #9969: [FLINK-14022][table-planner][table-planner-blink] Add validation check for places where Python ScalarFunction cannot be used URL: https://github.com/apache/flink/pull/9969#discussion_r339962865
########## File path: flink-table/flink-table-planner-blink/src/test/resources/org/apache/flink/table/planner/plan/rules/logical/SplitPythonConditionFromJoinRuleTest.xml ########## @@ -0,0 +1,79 @@ +<?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="testPythonFunctionInJoinCondition"> + <Resource name="sql"> + <![CDATA[SELECT a, b, d FROM leftTable JOIN rightTable ON a=d and pyFunc(a, d)=b ]]> + + </Resource> + <Resource name="planBefore"> + <![CDATA[ +LogicalProject(a=[$0], b=[$1], d=[$3]) ++- LogicalJoin(condition=[AND(=($0, $3), =(pyFunc($0, $3), $1))], joinType=[inner]) + :- LogicalTableScan(table=[[default_catalog, default_database, leftTable, source: [TestTableSource(a, b, c)]]]) + +- LogicalTableScan(table=[[default_catalog, default_database, rightTable, source: [TestTableSource(d, e, f)]]]) +]]> + + </Resource> + <Resource name="planAfter"> + <![CDATA[ +FlinkLogicalCalc(select=[a, b, d], where=[=(pyFunc(a, d), b)]) ++- FlinkLogicalJoin(condition=[=($0, $2)], joinType=[inner]) + :- FlinkLogicalCalc(select=[a, b]) + : +- FlinkLogicalTableSourceScan(table=[[default_catalog, default_database, leftTable, source: [TestTableSource(a, b, c)]]], fields=[a, b, c]) + +- FlinkLogicalCalc(select=[d]) + +- FlinkLogicalTableSourceScan(table=[[default_catalog, default_database, rightTable, source: [TestTableSource(d, e, f)]]], fields=[d, e, f]) +]]> + + </Resource> + </TestCase> + <TestCase name="testPythonFunctionInAboveFilter"> + <Resource name="sql"> + <![CDATA[ +SELECT a, d FROM( +SELECT a, d +FROM leftTable JOIN rightTable ON + a = d and pyFunc(a, a) = a + d) +WHERE pyFunc(a, d) = a * d + ]]> + + </Resource> + <Resource name="planBefore"> + <![CDATA[ +LogicalProject(a=[$0], d=[$1]) ++- LogicalFilter(condition=[=(pyFunc($0, $1), *($0, $1))]) + +- LogicalProject(a=[$0], d=[$3]) + +- LogicalJoin(condition=[AND(=($0, $3), =(pyFunc($0, $0), +($0, $3)))], joinType=[inner]) + :- LogicalTableScan(table=[[default_catalog, default_database, leftTable, source: [TestTableSource(a, b, c)]]]) + +- LogicalTableScan(table=[[default_catalog, default_database, rightTable, source: [TestTableSource(d, e, f)]]]) +]]> + + </Resource> + <Resource name="planAfter"> + <![CDATA[ +FlinkLogicalCalc(select=[a, d], where=[AND(=(pyFunc(a, a), +(a, d)), =(pyFunc(a, d), *(a, d)))]) Review comment: This plan is not valid. We can't handle a Calc mixed with java and python udfs. ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
